﻿using System;
using System.Xml;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.IO;
using Microsoft.Win32;
using System.Reflection;
using nm = NetworkManager;

namespace Shakes_and_Fidget___Charplaner
{
    public partial class sfc : Form
    {
        public sfc()
        {
            if (param.Length > 1 && param[1].ToString().EndsWith("sfc"))
            {
                InitializeComponent();
                RegisrtyStuff();
                //Open(param[1].ToString());
                active = false;
            }
            else
            {
                //AttributeInput();
                InitializeComponent();
                RegisrtyStuff();
            }
        }

		
        #region enums
        enum Stats
        {
            STRENGTH        = 1,
            DEXTERITY       = 2,
            INTELLIGENCE    = 3,
            STAMINA         = 4,
            LUCK            = 5,
            ALLSTATS        = 6,
			DUARTION		= 11,
			LIFE			= 16,
        }

        enum Slots
        {
            WEAPON          = 1,
            SHIELD          = 2,
            BREAST          = 3,
            FEET            = 4,
            HANDS           = 5,
            HELMET          = 6,
            BELT            = 7,
            NECKLACE        = 8,
            RING            = 9,
            TRINKET         = 10,
            KEY             = 11,
            FLASK           = 12,
        }

        enum CacheFormat
        {
            NULL0 = 0,				    //
            ACCOUNTID,			    	// Account ID
            NULL1,				    	// Timestamp
            NULL2,				    	// Timestamp Accounterstellung?
            NULL3,				    	//
            NULL4,				    	//
            NULL5,				    	//
            LEVEL,				    	// Level
            EXPERIENCE,			    	// Erfahrung zurzeit
            EXPERIENCELEVEL,			// Erfahrung für Levelaufstieg
            HONOR,						// Ehre
            RANK,						// Rangplatz
            NULL6,						//
            GOLD,						// Gold in Silber (Gold /= 100)
            MUSHROOMS,					// Pilze
            NULL7,						// 
            NULL8,						// 
            NULL9,						//
            NULL10,						// 
            NULL11,						// 
            NULL12,						//
            NULL13,						//
            NULL14,						//
            NULL15,						//
            NULL16,						//
            NULL17,						//
            NULL18,						//
            NULL19,						//
            NULL20,						//
            NULL21,						//
            BASESTR,					// Basis STR 
            BASEDEX,					// Basis GES 
            BASEINT,					// Basis INT 
            BASESTAM,					// Basis AUS 
            BASELUCK,					// Basis LUCK 
            BONUSSTR,					// Bonus STR
            BONUSDEX,					// Bonus GES
            BONUSINT,					// Bonus INT
            BONUSSTAM,					// Bonus AUS
            BONUSLUCK,					// Bonus LUCK
            STR0,						// ?STR
            DEX0,						// ?GES
            INT0,						// ?INT
            STAM0,						// ?AUS
            LUCK0,						// ?LUCK
            NULL22,						//
            NULL23,						//
            NULL24,						//
            HELMSLOTID,					// Helm Slot ID
            HELMLOOK,					// Aussehen
            HELMARMOR,					// Rüstung Helm
            NULL25,						// 
            HELMATRID1,					// Attribut 1 ID
            HELMATRID2,					// Attribut 2 ID
            HELMATRID3,					// Attribut 3 ID
            HEMLATR1,					// Attribut 1 +
            HELMATR2,					// Attribut 2 +
            HELMATR3,					// Attribut 3 +
            HELM0,					 	// Helm (Template) ID?
            NULL26,						// ------------------
			BREASTSLOTID,				// Brust Slot ID
            BREASTLOOK,					// Aussehen
            BREASTARMOR,				// Rüstung Brust
            NULL27,						//
            BREASTATRID1,				// Attribut 1 ID
			BREASTATRID2,				// Attribut 2 ID
			BREASTATRID3,				// Attribut 3 ID
			BREASTATR1,					// Attribut 1 +
			BREASTATR2,					// Attribut 2 + 
			BREASTATR3,					// Attribut 3 +
            BREAST0,					// Brust (Template) ID?
            NULL28,						// ------------------
            HANDSSLOTID,				// Hände Slot ID
			HANDSLOOK,					// Aussehen
            HANDSARMOR,					// Rüstung Hände
            NULL29,						//
			HANDSARTID1,				// Attribut 1 ID
			HANDSARTID2,				// Attribut 2 ID
            HANDSARTID3,				// Attribut 3 ID
            HANDSATR1,					// Attribut 1 +
			HANDSATR2,					// Attribut 2 +
            HANDSATR3,					// Attribut 3 +
            HANDS0,						// Hände (Template) ID?
            NULL30,						// ------------------
            FEETSLOTID,					// Füße Slot ID
			FEETLOOK,					// Aussehen
            FEETARMOR,					// Rüstung Füße
            NULL31,						//
            FEETATRID1,					// Attribut 1 ID
            FEETATRID2,					// Attribut 2 ID
            FEETATRID3,					// Attribut 3 ID
            FEETATR1,					// Attribut 1 +
            FEETATR2,					// Attribut 2 +
            FEETATR3,					// Attribut 3 +
            FEET0,						// Füße (Template) ID?
            NULL32,						// ------------------
            NECKSLOTID,					// Hals Slot ID
            NECKLOOK,					// Aussehen
            NECKARMOR,					// Rüstung Hals
            NULL33,						//
            NECKATRID1,					// Attribut 1 ID
			NECKATRID2,					// Attribut 2 ID
            NECKATRID3,					// Attribut 3 ID
            NECKATR1,					// Attribut 1 +
            NECKATR2,					// Attribut 2 +
            NECKATR3,					// Attribut 3 +
            NECK0,						// Hals (Template) ID?
            NULL34,						// ------------------
			BELTSLOTID,					// Gürtel Slot ID
            BELTLOOK,					// Aussehen
			BELTARMOR,					// Rüstung Gürtel
            NULL35,						//
            BELTATRID1,					// Attribut 1 ID
            BELTATRID2,					// Attribut 2 ID
            BELTATRID3,					// Attribut 3 ID
            BELTATR1,					// Attribut 1 +
            BELTATR2,					// Attribut 2 +
			BELTATR3,					// Attribut 3 +
            BELT0,						// Gürtel (Template) ID?
            NULL36,						// ------------------
            RINGSLOTID,					// Ring Slot ID
            RINGLOOK,					// Aussehen
            RINGARMOR,					// Rüstung Ring
            NULL37,						//
            RINGATRID1,					// Attribut 1 ID
            RINGATRID2,					// Attribut 2 ID
            RINGATRID3,					// Attribut 3 ID
            RINGATR1,					// Attribut 1 +
            RINGATR2,					// Attribut 2 +
            RINGATR3,					// Attribut 3 +
            RING0,						// Ring (Template) ID?
			NULL38,						// ------------------
            TRINKETSLOTID,				// Schmuck Slot ID
			TRINKETLOOK,				// Aussehen
            TRINKETARMOR,				// Rüstung Schmuck
			NULL39,						//
            TRINKETATRID1,				// Attribut 1 ID
            TRINKETATRID2,				// Attribut 2 ID
            TRINKETATRID3,				// Attribut 3 ID
            TRINKETATR1,				// Attribut 1 +
            TRINKETATR2,				// Attribut 2 +
            TRINKETATR3,				// Attribut 3 +
            TRINKET0,					// Schmuck (Template) ID?
			NULL40,						// ------------------
            WEAOPONSLOTID,				// Waffe Slot ID
            WEAPONLOOK,					// Aussehen
            WEAPONMINDMG,				// Waffe Min DMG
            WEAPONMAXDMG,				// Waffe Max DMG
            WEAPONATRID1,				// Attribut 1 ID
            WEAPONATRID2,				// Attribut 2 ID
            WEAPONATRI3,				// Attribut 3 ID
            WEAPONATR1,					// Attribut 1 +
            WEAPONATR2,					// Attribut 2 +
            WEAPONATR3,					// Attribut 3 +
            WEAPON0,					// Waffe (Template) ID?
            NULL41,						// ------------------
            SHIELDSLOTID,				// Schild Slot ID
			SHIELDLOOK,					// Aussehen
			SHIELDBLOCK,				// Blocken Schild
            NULL42,						// 
			SHIELDATRID1,				// Attribut 1 ID
            SHIELDATRID2,				// Attribut 2 ID
			SHIELDATRID3,				// Attribut 3 ID
			SHIELDATR1,					// Attribut 1 +
			SHIELDATR2,					// Attribut 2 +
			SHIELDATR3,					// Attribut 3 +
			SHIELD0,					// Schild (Template) ID?
            NULL43,						// ------------------
            INV1SLOTID,					// Slot ID
            INV1LOOK,					// Aussehen
            INV1MINDMG,					// Waffenschaden min
            INV1MAXDMG,					// Waffenschaden max
            INV1ATRID1,					// Slot 1 Stat 1 ID
            INV1ATRID2,					// Slot 1 Stat 2 ID
            INV1ATRID3,					// Slot 1 Stat 3 ID
            INV1ATR1,					// Slot 1 Stat 1 +
            INV1ATR2,					// Slot 1 Stat 2 +
            INV1ATR3,					// Slot 1 Stat 3 +
            NULL44,						// 
            NULL45,						// ------------------
            INV2SLOTID,					// Slot ID
            INV2LOOK,					// Aussehen
            INV2MINDMG,					// Waffenschaden min
            INV2MAXDMG,					// Waffenschaden max
            INV2ATRID1,					// Slot 2 Stat 1 ID
            INV2ATRID2,					// Slot 2 Stat 2 ID
            INV2ATRID3,					// Slot 2 Stat 3 ID
            INV2ATR1,					// Slot 2 Stat 1 +
            INV2ATR2,					// Slot 2 Stat 2 +
            INV2ATR3,					// Slot 2 Stat 3 +
            NULL46,						//
            NULL47,						// ------------------
            INV3SLOTID,					// Slot ID
            INV3LOOK,					// Aussehen
            INV3MINDMG,					// Waffenschaden min
            INV3AXDMG,					// Waffenschaden max
            INV3ATRID1,					// Slot 3 Stat 1 ID
            INV3ATRID2,					// Slot 3 Stat 2 ID
            INV3ATRID3,					// Slot 3 Stat 3 ID
            INV3ATR1,					// Slot 3 Stat 1 +
            INV3ATR2,					// Slot 3 Stat 2 +
            INV3ATR3,					// Slot 3 Stat 3 +
			NULL48,						//
            NULL49,						// ------------------
            INV4SLOTID,					// Slot ID
            INV4LOOK,					// Aussehen
            INV4MINDMG,					// Waffenschaden min
            INV4MAXDMG,					// Waffenschaden max
            INV4ATRID1,					// Slot 4 Stat 1 ID
            INV4ATRID2,					// Slot 4 Stat 2 ID
            INV4ATRID3,					// Slot 4 Stat 3 ID
            INV4ATR1,					// Slot 4 Stat 1 +
            INV4ATR2,					// Slot 4 Stat 2 +
            INV4ATR3,					// Slot 4 Stat 3 +
            NULL50,						//
            NULL51,						// ------------------
            INV5SLOTID,					// Slot ID
            INV5LOOK,					// Aussehen
            INV5MINDMG,					// Waffenschaden min
            INV5MAXDMG,					// Waffenschaden max
            INV5ATRID1,					// Slot 5 Stat 1 ID
            INV5ATRID2,					// Slot 5 Stat 2 ID
            INV5ATRID3,					// Slot 5 Stat 3 ID
            INV5ATR1,					// Slot 5 Stat 1 +
            INV5ATR2,					// Slot 5 Stat 2 +
            INV5ATR3,					// Slot 5 Stat 3 +
            NULL52,						//
			NULL53,						// ------------------
			NULL54,						//
			NULL55,						// Stat?
			NULL56,						// Stat?
			NULL57,						// Stat?
			NULL58,						// Stat ID?
			NULL59,						// Stat ID?
			NULL60,						// Stat ID?
			NULL61,						//
			NULL62,						//
			NULL63,						//
			NULL64,						//
			NULL65,						//
			NULL66,						//
			NULL67,						//
			NULL68,						//
			NULL69,						//
			NULL70,						//
			NULL71,						//
			NULL72,						//
			NULL73,						//
            NULL74,						//
            NULL75,						//
            NULL76,						//
            NULL77,						//
            NULL78,						//
            NULL79,						//
            NULL80,						//
            NULL81,						//
            NULL82,						//
            NULL83,						//
            NULL84,						//
            NULL85,						//
            NULL86,						//
            NULL87,						//
            NULL88,						//
            NULL89,						//
            NULL90,						//
            NULL91,						//
            NULL92,						//
            NULL93,						//
            NULL94,						//
            NULL95,						//
            NULL96,						//
            NULL97,						//
            NULL98,						//
            NULL99,						//
            NULL100,					//
            NULL101,					//
            NULL102,					//
            NULL103,					//
            NULL104,					//
            NULL105,					//
            NULL106,					//
            NULL107,					//
            NULL310,					//
            NULL108,					//
            NULL109,					//
            NULL110,					//
            NULL111,					//
            NULL112,					//
            NULL113,					//
            NULL114,					//
            NULL115,					//
            NULL116,					//
            NULL117,					//
            NULL118,					//
            NULL119,					//
            NULL120,					//
            NULL121,					//
            NULL122,					//
            NULL123,					//
            NULL124,					//
            NULL125,					//
            NULL126,					//
            NULL127,					//
            NULL128,					//
            NULL129,					//
            NULL130,					//
            NULL131,					//
            NULL132,					//
            NULL133,					//
            NULL134,					//
            NULL135,					//
            NULL136,					//
            NULL137,					//
            NULL138,					//
            NULL139,					//
            NULL140,					//
            NULL141,					//
            NULL142,					//
            NULL143,					//
            NULL144,					//
            NULL145,					//
            NULL146,					//
            NULL147,					//
            NULL148,					//
            NULL149,					//
            NULL150,					//
            NULL151,					//
            NULL152,					//
            NULL153,					//
            NULL154,					//
            NULL155,					//
            NULL156,					//
            NULL157,					//
            NULL158,					//
            NULL159,					//
            NULL160,					//
            NULL161,					//
            NULL162,					//
            NULL163,					//
            NULL164,					//
            NULL165,					//
            NULL166,					//
            NULL167,					//
            NULL168,					//
            NULL169,					//
            NULL170,					//
            NULL171,					//
            NULL172,					//
            NULL173,					//
            NULL174,					//
            NULL175,					//
            NULL176,					//
            NULL177,					//
            NULL178,					//
            NULL179,					//
            NULL180,					//
            NULL181,					//
            NULL182,					//
            NULL183,					//
            NULL184,					//
            NULL185,					//
            NULL186,					//
            NULL187,					//
            NULL188,					//
            NULL189,					//
            NULL190,					//
            NULL191,					//
            NULL192,					//
            NULL193,					//
            NULL194,					//
            NULL195,					//
            NULL196,					//
            NULL197,					//
            NULL198,					//
            NULL199,					//
            NULL200,					//
            NULL201,					//
            NULL202,					//
            NULL203,					//
            NULL204,					//
            NULL205,					//
            NULL206,					//
            NULL207,					//
            NULL208,					//
            NULL209,					//
            NULL210,					//
            NULL211,					//
            NULL222,					//
            NULL223,					//
            NULL224,					//
            NULL225,					//
            NULL226,					//
            NULL227,					//
            NULL228,					//
            NULL229,					//
            NULL230,					//
            NULL231,					//
            NULL232,					//
            NULL233,					//
            NULL234,					//
            NULL235,					//
            NULL236,					//
            NULL237,					//
            NULL238,					//
            NULL239,					//
            NULL240,					//
            NULL241,					//
            NULL242,					//
            NULL243,					//
            NULL244,					//
            NULL245,					//
            NULL246,					//
            NULL247,					//
            NULL248,					//
            NULL249,					//
            NULL250,					//
            NULL251,					//
            NULL252,					//
            NULL253,					//
            NULL254,					//
            NULL255,					//
            NULL256,					//
            NULL257,					//
            NULL258,					//
            NULL259,					//
            NULL260,					//
            NULL261,					//
            NULL262,					//
            NULL263,					//
            NULL264,					//
            NULL265,					//
            NULL266,					//
            NULL267,					//
            NULL268,					//
            NULL269,					//
            NULL270,					//
            NULL271,					//
            NULL272,					//
            NULL273,					//
            NULL274,					//
            NULL275,					//
            NULL276,					//
            NULL277,					//
            NULL278,					//
            NULL279,					//
            NULL280,					//
            NULL281,					//
            ARMOR,						// Rüstung
            NULL282,					//
            NULL283,					//
            NULL284,					//
            MOUNTEXPIRE,				// Mount Ende
            NULL285,					//
            NULL286,					//
            NULL287,					//
            NULL288,					//
            NULL289,					// 
            NULL290,					//
            DUNGEONTIERS1,				// Dungeonebenen gereinigt
            NULL291,					// ?
            NULL292,					// ?
            NULL293,					//
            NULL294,					//
            NULL295,					//
            ACCOUNTCREATION,			// Accountertellungsdatum
            LEVEL1,						// Level
            DUNGEONTIERS2,				// Dungeons gereinigt
            FIGHTSWON,					// Gewonnene Kämfpe
            ADVENTURESDONE,				// Abenteuer 
            WORKEDHOURS,				// Arbeitsstunden
            MONEYEARNED,				// Verdientes Geld
            HONOR2,						// Ehre
            FRIENDSCALLED,				// Freunde geworben
            NULL296,					//
            MEDALBONUS,					// Orden Bonus
            NULL297,					//
            NULL298,					//
            NULL299,					//
            LASTLOGIN0,					// Last Login ?
            NULL300,					//
            DUNGEON1,					// Dungeon 1
            DUNGEON2,					// Dungeon 2
            DUNGEON3,					// Dungeon 3
            DUNGEON4,					// Dungeon 4
            DUNGEON5,					// Dungeon 5
            DUNGEON6,					// Dungeon 6
            DUNGEON7,					// Dungeon 7
            DUNGEON8,					// Dungeon 8
            DUNGEON9,					// Dungeon 9
            DUNGEON10,					// Dungeon 10
            DUNGEON11,					// Dungeon 11
            DUNGEON12,					// Dungeon 12
            NULL301,					// ------------------
            FLASKID1,					// Trank 1 Stat ID
            FLASKID2,					// Trank 2 Stat ID
            FLASKID3,					// Trank 3 Stat ID
            FLASKTIMESTAMP1,			// Trank 1 Timestamp
            FLASKTIMESTAMP2,			// Trank 2 Timestamp
            FLASKTIMESTAMP3,			// Trank 3 Timestamp
            FLASKBONUS1,				// Trank 1 Bonus
            FLASKBONUS2,				// Trank 2 Bonus
            FLASKBONUS3,				// Trank 3 Bonus
            NULL302,					// 
            NULL303,					//
            NULL304,					//
            NULL305,					//
            NULL306,					//
            NULL307,					//
            NULL308,					//
            NULL309,					//
            TIMENOW,					// Time Now
            CHARDESCRIPTION,			// Charbeschreibung

        }

        enum Dungeon
        {
            CLOSED0         = 0,
            CLOSED1         = 1,
            STAGE1          = 2,
            STAGE2          = 3,
            STAGE3          = 4,
            STAGE4          = 5,
            STAGE5          = 6,
            STAGE6          = 7,
            STAGE7          = 8,
            STAGE8          = 9,
            STAGE9          = 10,
            STAGE10         = 11,
            CLEAR           = 12,
        }
        #endregion
		/**/
        #region zeuch
        StreamWriter log = Program.log;
        bool active = true;
        string[] param = Environment.GetCommandLineArgs();
        int mult = 1;
        public int base_str;
        public int base_ges;
        public int base_int;
        public int base_aus;
        public int base_luck;
        public int equip_str;
        public int equip_ges;
        public int equip_int;
        public int equip_aus;
        public int equip_luck;
        public int armor;
        public int dmg_red;
        public bool lifebonus;
        public int goldKostenMax = 0;
        public int attrKostenMax = 0;
        public int gildenKostenMax = 0;
        AttributeBox atr_input = new AttributeBox();
        bool calculated;
        #endregion

		#region conversions
		public int TI(string value)
		{
			return Convert.ToInt32(value);
		}
        public DateTime StampToTime(long timestamp)
        {
            DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            date = date.AddSeconds(timestamp);
            return date;
        }
        public long TimeToStamp(DateTime date)
        {
            TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0));
            long timestamp = (long)t.TotalSeconds;
            return timestamp;
        }
		#endregion

		#region bullshit :D
		public XmlDocument GetResource(string resourceCode)
        {
            XmlDocument xml = null;
            Stream fileStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Shakes_and_Fidget___Charplaner.Resources.skillkosten.xml");
            if (fileStream != null)
            {
                xml = new XmlDocument();
                xml.Load(fileStream);
            }

            return xml;
        }
        private void button7_Click(object sender, EventArgs e)
        {
            if (plr_armor.Text == "")
                return;
            plr_armor.Enabled = false;
            armor = TI(plr_armor.Text);
        }
        private void button6_Click(object sender, EventArgs e)
        {
            plr_armor.Enabled = true;
        }
        private void button5_Click(object sender, EventArgs e)
        {
            string class_ = plr_class.Text;
            switch (class_)
            {
                case "Magier":
                    //AddPoints(0, 0, 8, 2, 5);
                    def.Text = "Widerstand:";
                    def.Left += 1;
                    plr_class.Enabled = true;
                    break;
                case "Krieger":
                    //AddPoints(7, 2, 0, 5, 0);
                    plr_class.Enabled = true;
                    break;
                case "Kundschaftler":
                    //AddPoints(1, 7, 1, 4, 2);
                    def2.Text = "Ausweichen:";
                    def2.Left += 3;
                    plr_class.Enabled = true;
                    break;
            }
            plr_class.SelectedIndex = -1;
            plr_race.SelectedIndex = -1;
            plr_race.Enabled = true;
        }
        private void button4_Click_1(object sender, EventArgs e)
        {
            if (gd.Visible == true)
                gd.Visible = false;
            else
                gd.Visible = true;
        }
        private void lvl_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Enter)
                button2_Click(sender, e);
            if (e.KeyChar == (char)Keys.Escape)
                button3_Click(sender, e);
        }
		#region quest maus events
		private void q1_lenght_MouseClick(object sender, MouseEventArgs e)
        {
            if (q1_lenght.Text == "Länge")
                q1_lenght.Text = "";
        }
        private void q1_lenght_Leave(object sender, EventArgs e)
        {
            if (q1_lenght.Text == "")
                q1_lenght.Text = "Länge";
        }
        private void q1_gold_MouseClick(object sender, MouseEventArgs e)
        {
            if (q1_gold.Text == "Gold")
                q1_gold.Text = "";
        }
        private void q1_gold_Leave(object sender, EventArgs e)
        {
            if (q1_gold.Text == "")
                q1_gold.Text = "Gold";
        }
        private void q1_ep_MouseClick(object sender, MouseEventArgs e)
        {
            if (q1_ep.Text == "EP")
                q1_ep.Text = "";
        }
        private void q1_ep_Leave(object sender, EventArgs e)
        {
            if (q1_ep.Text == "")
                q1_ep.Text = "EP";
        }
        private void q2_lenght_MouseClick(object sender, MouseEventArgs e)
        {
            if (q2_lenght.Text == "Länge")
                q2_lenght.Text = "";
        }
        private void q2_lenght_Leave(object sender, EventArgs e)
        {
            if (q2_lenght.Text == "")
                q2_lenght.Text = "Länge";
        }
        private void q2_gold_MouseClick(object sender, MouseEventArgs e)
        {
            if (q2_gold.Text == "Gold")
                q2_gold.Text = "";
        }
        private void q2_gold_Leave(object sender, EventArgs e)
        {
            if (q2_gold.Text == "")
                q2_gold.Text = "Gold";
        }
        private void q2_ep_MouseClick(object sender, MouseEventArgs e)
        {
            if (q2_ep.Text == "EP")
                q2_ep.Text = "";
        }
        private void q2_ep_Leave(object sender, EventArgs e)
        {
            if (q2_ep.Text == "")
                q2_ep.Text = "EP";
        }
        private void q3_lenght_MouseClick(object sender, MouseEventArgs e)
        {
            if (q3_lenght.Text == "Länge")
                q3_lenght.Text = "";
        }
        private void q3_lenght_Leave(object sender, EventArgs e)
        {
            if (q3_lenght.Text == "")
                q3_lenght.Text = "Länge";
        }
        private void q3_gold_MouseClick(object sender, MouseEventArgs e)
        {
            if (q3_gold.Text == "Gold")
                q3_gold.Text = "";
        }
        private void q3_gold_Leave(object sender, EventArgs e)
        {
            if (q3_gold.Text == "")
                q3_gold.Text = "Gold";
        }
        private void q3_ep_MouseClick(object sender, MouseEventArgs e)
        {
            if (q3_ep.Text == "EP")
                q3_ep.Text = "";
        }
        private void q3_ep_Leave(object sender, EventArgs e)
        {
            if (q3_ep.Text == "")
                q3_ep.Text = "EP";
        }
		#endregion
		private void calc_q_Click(object sender, EventArgs e)
        {
            CalcQuests();
        }
        private void immerImVordergrundToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form settings = new settings();
            settings.Show();
        }
        private void Form1_MouseMove(object sender, MouseEventArgs e)
        {
            UpdateTooltip();
            AttrCosts();
            if (active)
                atr_input.BringToFront();
        }
        private void schließenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Dispose(true);
        }
		#region save&load
		private void d_load_FileOk(object sender, CancelEventArgs e)
        {
            Open(d_load.FileName);
        }
        private void b_open_Click(object sender, EventArgs e)
        {
            d_load.ShowDialog();
        }
        private void d_save_FileOk(object sender, CancelEventArgs e)
        {
            Save();
        }
        private void b_save_Click(object sender, EventArgs e)
        {
            d_save.ShowDialog();
        }
        private void btn_ok_Click(object sender, EventArgs e)
        {
            if (atr_input.l_aus.Text == "" || atr_input.l_ges.Text == "" || atr_input.l_int.Text == "" || atr_input.l_luck.Text == "" || atr_input.l_str.Text == "")
            {
                MessageBox.Show("Du hast ein Feld freigelassen");
                return;
            }
            AddPoints(TI(atr_input.l_str.Text), TI(atr_input.l_ges.Text), TI(atr_input.l_int.Text), TI(atr_input.l_aus.Text), TI(atr_input.l_luck.Text));
            AddBasePoints(TI(atr_input.l_str.Text), TI(atr_input.l_ges.Text), TI(atr_input.l_int.Text), TI(atr_input.l_aus.Text), TI(atr_input.l_luck.Text));
            atr_input.Hide();
            active = false;
            this.Enabled = true;
            UpdateTooltip();
        }
        private void btn_c_Click(object sender, EventArgs e)
        {
            atr_input.Hide();
            active = false;
            this.Enabled = true;
        }
		private void load_Click(object sender, EventArgs e)
		{
			if(atr_input.success)
				LoadChar(atr_input.characterinfo);
			atr_input.success = false;
		}
		#endregion
		private void button1_Click(object sender, EventArgs e)
        {
            FastAtr();
            UpdateTooltip();
        }
		#region plus events
		private void str_plus_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Control)
                mult = 5;
            else if (ModifierKeys == Keys.Shift)
                mult = -1;
            else if (ModifierKeys == Keys.Alt)
                mult = -5;
            else
                mult = 1;
            int val = TI(val_str.Text);
            AddPoints(mult, 0, 0, 0, 0);
            AddBasePoints(mult, 0, 0, 0, 0);
            UpdateTooltip();
            AttrCosts();
        }
        private void str_plus_MouseEnter(object sender, EventArgs e)
        {
            str_plus.Image = Properties.Resources.plus_h;
        }
        private void str_plus_MouseLeave(object sender, EventArgs e)
        {
            str_plus.Image = Properties.Resources.plus;
        }
        private void str_plus_MouseUp(object sender, MouseEventArgs e)
        {
            str_plus.Left -= 2;
            str_plus.Top -= 2;
        }
        private void str_plus_MouseDown(object sender, MouseEventArgs e)
        {
            str_plus.Left += 2;
            str_plus.Top += 2;
        }
        private void ges_plus_MouseDown(object sender, MouseEventArgs e)
        {
            ges_plus.Left += 2;
            ges_plus.Top += 2;
        }
        private void ges_plus_MouseEnter(object sender, EventArgs e)
        {
            ges_plus.Image = Properties.Resources.plus_h;
        }
        private void ges_plus_MouseLeave(object sender, EventArgs e)
        {
            ges_plus.Image = Properties.Resources.plus;
        }
        private void ges_plus_MouseUp(object sender, MouseEventArgs e)
        {
            ges_plus.Left -= 2;
            ges_plus.Top -= 2;
        }
        private void ges_plus_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Control)
                mult = 5;
            else if (ModifierKeys == Keys.Shift)
                mult = -1;
            else if (ModifierKeys == Keys.Alt)
                mult = -5;
            else
                mult = 1;
            AddPoints(0, mult, 0, 0, 0);
            AddBasePoints(0, mult, 0, 0, 0);
            UpdateTooltip();
        }
        private void int_plus_MouseUp(object sender, MouseEventArgs e)
        {
            int_plus.Left -= 2;
            int_plus.Top -= 2;
        }
        private void int_plus_MouseLeave(object sender, EventArgs e)
        {
            int_plus.Image = Properties.Resources.plus;
        }
        private void int_plus_MouseEnter(object sender, EventArgs e)
        {
            int_plus.Image = Properties.Resources.plus_h;
        }
        private void int_plus_MouseDown(object sender, MouseEventArgs e)
        {
            int_plus.Left += 2;
            int_plus.Top += 2;
        }
        private void int_plus_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Control)
                mult = 5;
            else if (ModifierKeys == Keys.Shift)
                mult = -1;
            else if (ModifierKeys == Keys.Alt)
                mult = -5;
            else
                mult = 1;
            AddPoints(0, 0, mult, 0, 0);
            AddBasePoints(0, 0, mult, 0, 0);
            UpdateTooltip();
        }
        private void aus_plus_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Control)
                mult = 5;
            else if (ModifierKeys == Keys.Shift)
                mult = -1;
            else if (ModifierKeys == Keys.Alt)
                mult = -5;
            else mult = 1;
            AddPoints(0, 0, 0, mult, 0);
            AddBasePoints(0, 0, 0, mult, 0);
            UpdateTooltip();
        }
        private void aus_plus_MouseDown(object sender, MouseEventArgs e)
        {
            aus_plus.Left += 2;
            aus_plus.Top += 2;
        }
        private void aus_plus_MouseEnter(object sender, EventArgs e)
        {
            aus_plus.Image = Properties.Resources.plus_h;
        }
        private void aus_plus_MouseLeave(object sender, EventArgs e)
        {
            aus_plus.Image = Properties.Resources.plus;
        }
        private void aus_plus_MouseUp(object sender, MouseEventArgs e)
        {
            aus_plus.Left -= 2;
            aus_plus.Top -= 2;
        }
        private void luck_plus_MouseUp(object sender, MouseEventArgs e)
        {
            luck_plus.Left -= 2;
            luck_plus.Top -= 2;
        }
        private void luck_plus_MouseLeave(object sender, EventArgs e)
        {
            luck_plus.Image = Properties.Resources.plus;
        }
        private void luck_plus_MouseEnter(object sender, EventArgs e)
        {
            luck_plus.Image = Properties.Resources.plus_h;
        }
        private void luck_plus_MouseDown(object sender, MouseEventArgs e)
        {
            luck_plus.Left += 2;
            luck_plus.Top += 2;
        }
        private void luck_plus_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Control)
                mult = 5;
            else if (ModifierKeys == Keys.Shift)
                mult = -1;
            else if (ModifierKeys == Keys.Alt)
                mult = -5;
            else
                mult = 1;
            AddPoints(0, 0, 0, 0, mult);
            AddBasePoints(0, 0, 0, 0, mult);
            UpdateTooltip();
        }
		#endregion
		private void plr_class_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (plr_class.SelectedItem != null)
                SetClass(plr_class.SelectedItem.ToString());
        }
        private void plr_race_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (plr_race.SelectedItem != null)
                SetRace(plr_race.SelectedItem.ToString());
        }
        private void button2_Click(object sender, EventArgs e)
        {
            lvl.Enabled = false;
            lvl_op.Enabled = false;
        }
        private void button3_Click(object sender, EventArgs e)
        {
            lvl.Enabled = true;
            lvl_op.Enabled = true;
        }
        private void reset_Click(object sender, EventArgs e)
        {
            val_aus.Text = "0";
            val_crit.Text = "0,00";
            val_def.Text = "0";
            val_def2.Text = "0";
            val_ges.Text = "0";
            val_int.Text = "0";
            val_life.Text = "0";
            val_luck.Text = "0";
            val_str.Text = "0";
            plr_class.Enabled = true;
            plr_race.Enabled = true;
            AttributeInput();
        }
        private void waffe_min_MouseClick(object sender, MouseEventArgs e)
        {
            if (waffe_min.Text == "min Dmg")
                waffe_min.Text = "";
        }
        private void waffe_min_Leave(object sender, EventArgs e)
        {
            if (waffe_min.Text == "")
                waffe_min.Text = "min Dmg";
        }
        private void waffe_max_MouseClick(object sender, MouseEventArgs e)
        {
            if (waffe_max.Text == "max Dmg")
                waffe_max.Text = "";
        }
        private void waffe_max_Leave(object sender, EventArgs e)
        {
            if (waffe_max.Text == "")
                waffe_max.Text = "max Dmg";
        }
        private void label25_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.sfgame.de/");
            label25.ForeColor = Color.DarkViolet;
        }
        private void button4_Click(object sender, EventArgs e)
        {
            CalculateStats(plr_class.Text);
        }
		#region Resetzeug
		private void kopf_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(kopf__1.Text), TI(kopf__2.Text), TI(kopf__3.Text), kopf_1.Text, kopf_2.Text, kopf_3.Text);
            kopf__1.Text = "0";
            kopf__2.Text = "0";
            kopf__3.Text = "0";
            kopf_1.SelectedIndex = -1;
            kopf_2.SelectedIndex = -1;
            kopf_3.SelectedIndex = -1;
            g_kopf.Enabled = true;
        }
        private void kopf_ok_Click(object sender, EventArgs e)
        {
            g_kopf.Enabled = false;
            EquipHandler(TI(kopf__1.Text), TI(kopf__2.Text), TI(kopf__3.Text), kopf_1.Text, kopf_2.Text, kopf_3.Text);
            UpdateTooltip();
        }
        private void brust_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(brust__1.Text), TI(brust__2.Text), TI(brust__3.Text), brust_1.Text, brust_2.Text, brust_3.Text);
            brust__1.Text = "0";
            brust__2.Text = "0";
            brust__3.Text = "0";
            brust_1.SelectedIndex = -1;
            brust_2.SelectedIndex = -1;
            brust_3.SelectedIndex = -1;
            g_brust.Enabled = true;
        }
        private void brust_ok_Click(object sender, EventArgs e)
        {
            g_brust.Enabled = false;
            brust_reset.Enabled = true;
            EquipHandler(TI(brust__1.Text), TI(brust__2.Text), TI(brust__3.Text), brust_1.Text, brust_2.Text, brust_3.Text);
            UpdateTooltip();
        }
        private void hand_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(hand__1.Text), TI(hand__2.Text), TI(hand__3.Text), hand_1.Text, hand_2.Text, hand_3.Text);
            hand__1.Text = "0";
            hand__2.Text = "0";
            hand__3.Text = "0";
            hand_1.SelectedIndex = -1;
            hand_2.SelectedIndex = -1;
            hand_3.SelectedIndex = -1;
            g_hand.Enabled = true;
        }
        private void hand_ok_Click(object sender, EventArgs e)
        {
            g_hand.Enabled = false;
            hand_reset.Enabled = true;
            EquipHandler(TI(hand__1.Text), TI(hand__2.Text), TI(hand__3.Text), hand_1.Text, hand_2.Text, hand_3.Text);
            UpdateTooltip();
        }
        private void fuß_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(füße__1.Text), TI(füße__2.Text), TI(füße__3.Text), füße_1.Text, füße_2.Text, füße_3.Text);
            füße__1.Text = "0";
            füße__2.Text = "0";
            füße__3.Text = "0";
            füße_1.SelectedIndex = -1;
            füße_2.SelectedIndex = -1;
            füße_3.SelectedIndex = -1;
            g_fuß.Enabled = true;
        }
        private void fuß_ok_Click(object sender, EventArgs e)
        {
            g_fuß.Enabled = false;
            fuß_reset.Enabled = true;
            EquipHandler(TI(füße__1.Text), TI(füße__2.Text), TI(füße__3.Text), füße_1.Text, füße_2.Text, füße_3.Text);
            UpdateTooltip();
        }
        private void schild_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(schild__1.Text), TI(schild__2.Text), TI(schild__3.Text), schild_1.Text, schild_2.Text, schild_3.Text);
            schild__1.Text = "0";
            schild__2.Text = "0";
            schild__3.Text = "0";
            schild_1.SelectedIndex = -1;
            schild_2.SelectedIndex = -1;
            schild_3.SelectedIndex = -1;
            g_schild.Enabled = true;
        }
        private void schild_ok_Click(object sender, EventArgs e)
        {
            g_schild.Enabled = false;
            schild_reset.Enabled = true;
            EquipHandler(TI(schild__1.Text), TI(schild__2.Text), TI(schild__3.Text), schild_1.Text, schild_2.Text, schild_3.Text);
            UpdateTooltip();
        }
        private void waffe_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(waffe__1.Text), TI(waffe__2.Text), TI(waffe__3.Text), waffe_1.Text, waffe_2.Text, waffe_3.Text);
            waffe__1.Text = "0";
            waffe__2.Text = "0";
            waffe__3.Text = "0";
            waffe_1.SelectedIndex = -1;
            waffe_2.SelectedIndex = -1;
            waffe_3.SelectedIndex = -1;
            waffe_min.Text = "min Dmg";
            waffe_max.Text = "max Dmg";
            g_waffe.Enabled = true;
        }
        private void waffe_ok_Click(object sender, EventArgs e)
        {
            g_waffe.Enabled = false;
            waffe_reset.Enabled = true;
            EquipHandler(TI(waffe__1.Text), TI(waffe__2.Text), TI(waffe__3.Text), waffe_1.Text, waffe_2.Text, waffe_3.Text);
            UpdateTooltip();
        }
        private void hals_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(hals__1.Text), TI(hals__2.Text), TI(hals__3.Text), hals_1.Text, hals_2.Text, hals_3.Text);
            hals__1.Text = "0";
            hals__2.Text = "0";
            hals__3.Text = "0";
            hals_1.SelectedIndex = -1;
            hals_2.SelectedIndex = -1;
            hals_3.SelectedIndex = -1;
            g_hals.Enabled = true;
        }
        private void hals_ok_Click(object sender, EventArgs e)
        {
            g_hals.Enabled = false;
            hals_reset.Enabled = true;
            EquipHandler(TI(hals__1.Text), TI(hals__2.Text), TI(hals__3.Text), hals_1.Text, hals_2.Text, hals_3.Text);
            UpdateTooltip();
        }
        private void gürtle_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(gürtel__1.Text), TI(gürtel__2.Text), TI(gürtel__3.Text), gürtel_1.Text, gürtel_2.Text, gürtel_3.Text);
            gürtel__1.Text = "0";
            gürtel__2.Text = "0";
            gürtel__3.Text = "0";
            gürtel_1.SelectedIndex = -1;
            gürtel_2.SelectedIndex = -1;
            gürtel_3.SelectedIndex = -1;
            g_gurt.Enabled = true;
        }
        private void gürtle_ok_Click(object sender, EventArgs e)
        {
            g_gurt.Enabled = false;
            gürtle_reset.Enabled = true;
            EquipHandler(TI(gürtel__1.Text), TI(gürtel__2.Text), TI(gürtel__3.Text), gürtel_1.Text, gürtel_2.Text, gürtel_3.Text);
            UpdateTooltip();
        }
        private void finger_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(finger__1.Text), TI(finger__2.Text), TI(finger__3.Text), finger_1.Text, finger_2.Text, finger_3.Text);
            finger__1.Text = "0";
            finger__2.Text = "0";
            finger__3.Text = "0";
            finger_1.SelectedIndex = -1;
            finger_2.SelectedIndex = -1;
            finger_3.SelectedIndex = -1;
            g_finger.Enabled = true;
        }
        private void finger_ok_Click(object sender, EventArgs e)
        {
            g_finger.Enabled = false;
            finger_reset.Enabled = true;
            EquipHandler(TI(finger__1.Text), TI(finger__2.Text), TI(finger__3.Text), finger_1.Text, finger_2.Text, finger_3.Text);
            UpdateTooltip();
        }
        private void schmuck_reset_Click(object sender, EventArgs e)
        {
            EquipHandler2(TI(schmuck__1.Text), TI(schmuck__2.Text), TI(schmuck__3.Text), schmuck_1.Text, schmuck_2.Text, schmuck_3.Text);
            schmuck__1.Text = "0";
            schmuck__2.Text = "0";
            schmuck__3.Text = "0";
            schmuck_1.SelectedIndex = -1;
            schmuck_2.SelectedIndex = -1;
            schmuck_3.SelectedIndex = -1;
            g_schmuck.Enabled = true;
        }
        private void schmuck_ok_Click(object sender, EventArgs e)
        {
            g_schmuck.Enabled = false;
            schmuck_reset.Enabled = true;
            EquipHandler(TI(schmuck__1.Text), TI(schmuck__2.Text), TI(schmuck__3.Text), schmuck_1.Text, schmuck_2.Text, schmuck_3.Text);
            UpdateTooltip();
        }
        private void reset_items_Click(object sender, EventArgs e)
        {
            kopf_reset_Click(sender, e);
            hals_reset_Click(sender, e);
            gürtle_reset_Click(sender, e);
            waffe_reset_Click(sender, e);
            schild_reset_Click(sender, e);
            brust_reset_Click(sender, e);
            fuß_reset_Click(sender, e);
            hand_reset_Click(sender, e);
            finger_reset_Click(sender, e);
            schmuck_reset_Click(sender, e);
            calculated = false;
            UpdateTooltip();
        }
		#endregion
		#endregion

		void RegisrtyStuff()
        {
            try
            {
                RegistryKey cr = Registry.ClassesRoot;
                RegistryKey lm = Registry.LocalMachine;
                if (lm.OpenSubKey("Software", true).OpenSubKey("SFC", true) != null && lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true) != null)
                {
                    Opacity = (int)lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).GetValue("Opacity") / 100.00;
                    if ((string)lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).GetValue("Path") != "")
                    {
                        d_save.InitialDirectory = (string)lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).GetValue("Path");
                        d_load.InitialDirectory = (string)lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).GetValue("Path");
                    }
                    string b = (string)lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).GetValue("TopMost");
                    if (b == "False")
                    {
                        TopMost = false;
                        atr_input.TopMost = false;
                        atr_input.BringToFront();
                    }
                    else if (b == "True")
                    {
                        TopMost = true;
                        atr_input.TopMost = true;
                        atr_input.BringToFront();
                    }
                }
                if (cr.OpenSubKey(".sfc") == null || lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).GetValue("Extension") == null)
                {
                    lm.OpenSubKey("Software", true).CreateSubKey("SFC").SetValue("Path", Environment.CurrentDirectory + "\\Shakes and Fidget Charplaner.exe");
                    lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).CreateSubKey("Settings").SetValue("Opacity", 100);
                    lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).SetValue("TopMost", false);
                    lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).OpenSubKey("Settings", true).SetValue("Path", "");
                    DialogResult res = MessageBox.Show("Soll die Dateiendung .sfc mit diesem Programm verknüpft werden?\r\n(Nein = Nie)", "Charakterplaner", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                    if (res == DialogResult.Cancel)
                    {
                        lm.Close();
                        return;
                    }
                    else
                    {
                        lm.OpenSubKey("Software", true).OpenSubKey("SFC", true).SetValue("Extension", res.ToString());
                        lm.Close();
                        if (res.ToString() == "Yes")
                        {
                            Properties.Resources.sficon.Save(Environment.SystemDirectory + "\\sficon.ico", System.Drawing.Imaging.ImageFormat.Icon);
                        }
                    }
                    if (res == DialogResult.No)
                        return;
                }
                if (cr.OpenSubKey(".sfc") == null)
                {
                    cr.CreateSubKey(".sfc", RegistryKeyPermissionCheck.ReadWriteSubTree);
                    cr.OpenSubKey(".sfc", true).SetValue("", "characterfile");
                    cr.CreateSubKey("characterfile");
                    //cr.OpenSubKey("characterfile", true).SetValue("", "Shakes & Fidget Charakterdatei");
                    //cr.OpenSubKey("characterfile", true).SetValue("BrowserFlags", 8, RegistryValueKind.DWord);
                    //cr.OpenSubKey("characterfile", true).SetValue("EditFlags", 0, RegistryValueKind.DWord);
                    cr.OpenSubKey("characterfile", true).CreateSubKey("DefaultIcon").SetValue("", Environment.SystemDirectory + "\\sficon.ico");
                    cr.OpenSubKey(".sfc", true).CreateSubKey("ShellNew").SetValue("NullFile", "");
                }
                cr.OpenSubKey("characterfile", true).CreateSubKey("shell").CreateSubKey("Open").CreateSubKey("command").SetValue("", Environment.CurrentDirectory + "\\Shakes and Fidget Charplaner.exe %1");
                cr.Close();
            }
            catch (Exception e)
            { Program.LogWrite(e); }
        }

        protected bool OnDispose()
        {
            DialogResult sure = MessageBox.Show("Willst du deine Änderungen speichern?", "Charakterplaner", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
            if (sure == DialogResult.Yes)
                d_save.ShowDialog();
            else if (sure == DialogResult.Cancel)
                return false;
            return true;
        }

        #region charplaner
		
        string[] GetCostByLevel(int points)
        {
            string[] cost = new string[2];
            cost[0] = "0";
            cost[1] = "0";
            if (points <= 0)
                return cost;
            XmlDocument xmldoc = GetResource("");
            XmlNodeList l = xmldoc.GetElementsByTagName("ooo_row");
            for (int i = 0; i < l.Count; i++)
            {
                if (l[i].FirstChild.InnerText == points.ToString())
                {
                    if (l[i].LastChild.InnerText.IndexOf('.') != -1)
                        cost = l[i].LastChild.InnerText.Split('.');
                    else
                    {
                        cost[0] = l[i].LastChild.InnerText;
                        cost[1] = "0";
                    }
                    if (cost[1].Length == 1)
                        cost[1] += "0";
                    break;
                }
            }
            return cost;

        }
        void AttrCosts()
        {
            gold_str.Text = GetCostByLevel(base_str)[0];
            silver_str.Text = GetCostByLevel(base_str)[1];
            gold_ges.Text = GetCostByLevel(base_ges)[0];
            silver_ges.Text = GetCostByLevel(base_ges)[1];
            gold_int.Text = GetCostByLevel(base_int)[0];
            silver_int.Text = GetCostByLevel(base_int)[1];
            gold_aus.Text = GetCostByLevel(base_aus)[0];
            silver_aus.Text = GetCostByLevel(base_aus)[1];
            gold_luck.Text = GetCostByLevel(base_luck)[0];
            silver_luck.Text = GetCostByLevel(base_luck)[1];
        }
		
		#region trankzeug
		private void trank_1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (trank_1.Text)
            {
                case "Stärke":
                    p_t1.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t1.Size = new Size(50, 40);
                    p_t1.Image = Properties.Resources.p_str;
                    break;
                case "Geschick":
                    p_t1.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t1.Size = new Size(50, 40);
                    p_t1.Image = Properties.Resources.p_ges;
                    break;
                case "Intelligenz":
                    p_t1.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t1.Size = new Size(50, 40);
                    p_t1.Image = Properties.Resources.p_int;
                    break;
                case "Ausdauer":
                    p_t1.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t1.Size = new Size(50, 40);
                    p_t1.Image = Properties.Resources.p_aus;
                    break;
                case "Glück":
                    p_t1.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t1.Size = new Size(50, 40);
                    p_t1.Image = Properties.Resources.p_luck1;
                    break;
                case "25% Lebensenergie":
                    p_t1.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t1.Size = new Size(50, 40);
                    p_t1.Image = Properties.Resources.p_life;
                    break;
                default:
                    p_t1.SizeMode = PictureBoxSizeMode.AutoSize;
                    p_t1.Image = Properties.Resources.p_no;
                    break;
            }
        }
        private void trank_2_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (trank_2.Text)
            {
                case "Stärke":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_str;
                    break;
                case "Geschick":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_ges;
                    break;
                case "Intelligenz":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_int;
                    break;
                case "Ausdauer":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_aus;
                    break;
                case "Glück":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_luck;
                    break;
                case "25% Lebensenergie":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_life;
                    break;
                default:
                    p_t2.SizeMode = PictureBoxSizeMode.AutoSize;
                    p_t2.Image = Properties.Resources.p_no;
                    break;
            }
        }
        private void trank_3_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (trank_3.Text)
            {
                case "Stärke":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t3.Image = Properties.Resources.p_str;
                    break;
                case "Geschick":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t3.Image = Properties.Resources.p_ges;
                    break;
                case "Intelligenz":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t3.Image = Properties.Resources.p_int;
                    break;
                case "Ausdauer":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t3.Image = Properties.Resources.p_aus;
                    break;
                case "Glück":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t3.Image = Properties.Resources.p_luck;
                    break;
                case "25% Lebensenergie":
                    p_t2.SizeMode = PictureBoxSizeMode.StretchImage;
                    p_t2.Size = new Size(50, 40);
                    p_t2.Image = Properties.Resources.p_life;
                    break;
                default:
                    p_t3.SizeMode = PictureBoxSizeMode.AutoSize;
                    p_t3.Image = Properties.Resources.p_no;
                    break;
            }
        }
        private void trank_1_ok_Click(object sender, EventArgs e)
        {
            if (p_tt1.Text != "" && trank_1.Text != "" || trank_1.Text == "25% Lebensenergie")
            {
                switch (trank_1.Text)
                {
                    case "Stärke":
                        AddPoints(TI(p_tt1.Text), 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, TI(p_tt1.Text), 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, TI(p_tt1.Text), 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, TI(p_tt1.Text), 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, TI(p_tt1.Text));
                        break;
                    case "25% Lebensenergie":
                        lifebonus = true;
                        break;
                }
                trank_1_res.Enabled = true;
                trank_1_ok.Enabled = false;
                p_tt1.Enabled = false;
                trank_1.Enabled = false;
            }
        }
        private void trank_2_ok_Click(object sender, EventArgs e)
        {
            if (p_tt2.Text != "" && trank_2.Text != "" || trank_1.Text == "25% Lebensenergie")
            {
                switch (trank_2.Text)
                {
                    case "Stärke":
                        AddPoints(TI(p_tt2.Text), 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, TI(p_tt2.Text), 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, TI(p_tt2.Text), 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, TI(p_tt2.Text), 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, TI(p_tt2.Text));
                        break;
                    case "25% Lebensenergie":
                        lifebonus = true;
                        break;
                }
                trank_2_res.Enabled = true;
                trank_2_ok.Enabled = false;
                p_tt2.Enabled = false;
                trank_2.Enabled = false;
            }
        }
        private void trank_3_ok_Click(object sender, EventArgs e)
        {
            if (p_tt3.Text != "" && trank_3.Text != "" || trank_1.Text == "25% Lebensenergie")
            {
                switch (trank_3.Text)
                {
                    case "Stärke":
                        AddPoints(TI(p_tt3.Text), 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, TI(p_tt3.Text), 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, TI(p_tt3.Text), 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, TI(p_tt3.Text), 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, TI(p_tt3.Text));
                        break;
                    case "25% Lebensenergie":
                        lifebonus = true;
                        break;
                }
                trank_3_res.Enabled = true;
                trank_3_ok.Enabled = false;
                p_tt3.Enabled = false;
                trank_3.Enabled = false;
            }
        }
        private void trank_1_res_Click(object sender, EventArgs e)
        {
            switch (trank_1.Text)
            {
                case "Stärke":
                    AddPoints(-(TI(p_tt1.Text)), 0, 0, 0, 0);
                    break;
                case "Geschick":
                    AddPoints(-0, -(TI(p_tt1.Text)), 0, 0, 0);
                    break;
                case "Intelligenz":
                    AddPoints(0, 0, -(TI(p_tt1.Text)), 0, 0);
                    break;
                case "Ausdauer":
                    AddPoints(0, 0, 0, -(TI(p_tt1.Text)), 0);
                    break;
                case "Glück":
                    AddPoints(0, 0, 0, 0, -(TI(p_tt1.Text)));
                    break;
                case "25% Lebensenergie":
                    lifebonus = false;
                    break;
            }
            trank_1_res.Enabled = false;
            trank_1_ok.Enabled = true;
            p_tt1.Enabled = true;
            trank_1.Enabled = true;
            p_tt1.Text = "";
            trank_1.SelectedIndex = 0;

        }
        private void trank_2_res_Click(object sender, EventArgs e)
        {
            switch (trank_2.Text)
            {
                case "Stärke":
                    AddPoints(-(TI(p_tt2.Text)), 0, 0, 0, 0);
                    break;
                case "Geschick":
                    AddPoints(-0, -(TI(p_tt2.Text)), 0, 0, 0);
                    break;
                case "Intelligenz":
                    AddPoints(0, 0, -(TI(p_tt2.Text)), 0, 0);
                    break;
                case "Ausdauer":
                    AddPoints(0, 0, 0, -(TI(p_tt2.Text)), 0);
                    break;
                case "Glück":
                    AddPoints(0, 0, 0, 0, -(TI(p_tt2.Text)));
                    break;
                case "25% Lebensenergie":
                    lifebonus = false;
                    break;
            }
            trank_2_res.Enabled = false;
            trank_2_ok.Enabled = true;
            p_tt2.Enabled = true;
            trank_2.Enabled = true;
            p_tt2.Text = "";
            trank_2.SelectedIndex = 0;
        }
        private void trank_3_res_Click(object sender, EventArgs e)
        {
            switch (trank_3.Text)
            {
                case "Stärke":
                    AddPoints(-(TI(p_tt3.Text)), 0, 0, 0, 0);
                    break;
                case "Geschick":
                    AddPoints(-0, -(TI(p_tt3.Text)), 0, 0, 0);
                    break;
                case "Intelligenz":
                    AddPoints(0, 0, -(TI(p_tt3.Text)), 0, 0);
                    break;
                case "Ausdauer":
                    AddPoints(0, 0, 0, -(TI(p_tt3.Text)), 0);
                    break;
                case "Glück":
                    AddPoints(0, 0, 0, 0, -(TI(p_tt3.Text)));
                    break;
                case "25% Lebensenergie":
                    lifebonus = false;
                    break;
            }
            trank_3_res.Enabled = false;
            trank_3_ok.Enabled = true;
            p_tt3.Enabled = true;
            trank_3.Enabled = true;
            p_tt3.Text = "";
            trank_3.SelectedIndex = 0;

        }
        private void p_t1_MouseHover(object sender, EventArgs e)
        {
            if (p_t1.Size != new Size(27, 40))
                points.SetToolTip(p_t1, trank_1.Text + " + " + p_tt1.Text);
            else
                points.SetToolTip(p_t1, "");
        }
        private void p_t2_MouseHover(object sender, EventArgs e)
        {
            if (p_t2.Size != new Size(27, 40))
                points.SetToolTip(p_t2, trank_2.Text + " + " + p_tt2.Text);
            else
                points.SetToolTip(p_t2, "");
        }
        private void p_t3_MouseHover(object sender, EventArgs e)
        {
            if (p_t3.Size != new Size(27, 40))
                points.SetToolTip(p_t3, trank_3.Text + " + " + p_tt3.Text);
            else
                points.SetToolTip(p_t3, "");
        }
		#endregion
		
		void FastAtr()
        {
            try
            {
                if (atrs.GetItemChecked(5))
                {
                    int val = TI(atr_fast.Text);
                    AddPoints(val, val, val, val, val);
                    return;
                }
                if (atrs.GetItemChecked(0))
                {
                    int val = TI(atr_fast.Text);
                    AddPoints(val, 0, 0, 0, 0);
                }
                if (atrs.GetItemChecked(1))
                {
                    int val = TI(atr_fast.Text);
                    AddPoints(0, val, 0, 0, 0);
                }
                if (atrs.GetItemChecked(2))
                {
                    int val = TI(atr_fast.Text);
                    AddPoints(0, 0, val, 0, 0);
                }
                if (atrs.GetItemChecked(3))
                {
                    int val = TI(atr_fast.Text);
                    AddPoints(0, 0, 0, val, 0);
                }
                if (atrs.GetItemChecked(4))
                {
                    int val = TI(atr_fast.Text);
                    AddPoints(0, 0, 0, 0, val);
                }
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }

        }
        void SetClass(string class_)
        {
            EventArgs e = new EventArgs();
            object sender = new object();
            try
            {
                switch (class_)
                {
                    case "Magier":
                        //AddPoints(0, 0, 8, 2, 5);
                        def.Text = "Verteidigung:";
                        def.Left -= 1;
                        schild_reset.Enabled = false;
                        schild_reset_Click(sender, e);
                        plr_class.Enabled = false;
                        g_schild.Enabled = false;
                        break;
                    case "Krieger":
                        //AddPoints(7, 2, 0, 5, 0);
                        schild_reset_Click(sender, e);
                        plr_class.Enabled = false;
                        break;
                    case "Kundschaftler":
                        //AddPoints(1, 7, 1, 4, 2);
                        def2.Text = "Verteidigung:";
                        def2.Left -= 3;
                        schild_reset.Enabled = false;
                        plr_class.Enabled = false;
                        schild_reset_Click(sender, e);
                        g_schild.Enabled = false;
                        break;
                }
            }
            catch (Exception ex)
            {
                Program.LogWrite(ex);
            }
        }
        void SetRace(string race)
        {
            try
            {
                switch (race)
                {
                    case "Mensch":
                        plr_race.Enabled = false;
                        break;
                    case "Elf":
                        //AddPoints(-1, 2, 0, -1, 0);
                        plr_race.Enabled = false;
                        break;
                    case "Zwerg":
                        //AddPoints(0, -2, 1, 2, 1);
                        plr_race.Enabled = false;
                        break;
                    case "Gnom":
                        //AddPoints(-2, 3, -1, -1, 1);
                        plr_race.Enabled = false;
                        break;
                    case "--------":
                        break;
                    case "Ork":
                        //AddPoints(1, 0, -1, 0, 0);
                        plr_race.Enabled = false;
                        break;
                    case "Dunkelelf":
                        //AddPoints(-2, 2, 1, -1, 0);
                        plr_race.Enabled = false;
                        break;
                    case "Goblin":
                        //AddPoints(-2, 2, 0, -1, 1);
                        plr_race.Enabled = false;
                        break;
                    case "Dämon":
                        //AddPoints(3, -1, 0, 1, -3);
                        plr_race.Enabled = false;
                        break;
                }
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void AddPoints(int str, int ges, int int_, int aus, int luck)
        {
            try
            {
                int val = TI(val_str.Text);
                val += str;
                val_str.Text = val.ToString();
                val = TI(val_ges.Text);
                val += ges;
                val_ges.Text = val.ToString();
                val = TI(val_int.Text);
                val += int_;
                val_int.Text = val.ToString();
                val = TI(val_aus.Text);
                val += aus;
                val_aus.Text = val.ToString();
                val = TI(val_luck.Text);
                val += luck;
                val_luck.Text = val.ToString();
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void AddEquipPoints(int str, int ges, int int_, int aus, int luck)
        {
            try
            {
                equip_str += str;
                equip_ges += ges;
                equip_int += int_;
                equip_aus += aus;
                equip_luck += luck;
            }
            catch (Exception e)
            {

                Program.LogWrite(e);
            }
        }
        void AddBasePoints(int str, int ges, int int_, int aus, int luck)
        {
            try
            {
                base_str += str;
                base_ges += ges;
                base_int += int_;
                base_aus += aus;
                base_luck += luck;
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void UpdateTooltip()
        {
            try
            {
                AddBasePoints(0, 0, 0, 0, 0);
                AddEquipPoints(0, 0, 0, 0, 0);
                points.SetToolTip(str_plus, "Equip: " + equip_str.ToString() + "\r\nBasis: " + base_str.ToString());
                points.SetToolTip(ges_plus, "Equip: " + equip_ges.ToString() + "\r\nBasis: " + base_ges.ToString());
                points.SetToolTip(int_plus, "Equip: " + equip_int.ToString() + "\r\nBasis: " + base_int.ToString());
                points.SetToolTip(aus_plus, "Equip: " + equip_aus.ToString() + "\r\nBasis: " + base_aus.ToString());
                points.SetToolTip(luck_plus, "Equip: " + equip_luck.ToString() + "\r\nBasis: " + base_luck.ToString());
                points.SetToolTip(val_str, "Equip: " + equip_str.ToString() + "\r\nBasis: " + base_str.ToString());
                points.SetToolTip(val_ges, "Equip: " + equip_ges.ToString() + "\r\nBasis: " + base_ges.ToString());
                points.SetToolTip(val_int, "Equip: " + equip_int.ToString() + "\r\nBasis: " + base_int.ToString());
                points.SetToolTip(val_aus, "Equip: " + equip_aus.ToString() + "\r\nBasis: " + base_aus.ToString());
                points.SetToolTip(val_luck, "Equip: " + equip_luck.ToString() + "\r\nBasis: " + base_luck.ToString());
                if (plr_class.Text == "Krieger")
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -50%)");
                else if (plr_class.Text == "Magier")
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -10%)");
                else if (plr_class.Text == "Kundschaftler")
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -25%)");
                else
                    points.SetToolTip(p_armor, "Schaden durch Gegner der Stufe " + lvl.Text + ": -" + dmg_red.ToString() + "% (max -0%)");
                if (lifebonus)
                    points.SetToolTip(val_life, TI(val_life.Text) / 1.25 + " + " + val_life);
                else
                    points.SetToolTip(val_life, val_life.Text);
                if ((lvl_op.Text == "" || lvl_op.Text == "0") && (lvl.Text != "" || lvl.Text != "0"))
                    points.SetToolTip(crit, "Gegen Gegner der Stufe " + lvl.Text + ": " + "");
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void CalculateStats(string class_)
        {
            try
            {
                if (waffe_min.Text == "min Dmg" || waffe_max.Text == "max Dmg")
                {
                    MessageBox.Show("Bitte trage den Waffenschaden ein!");
                    return;
                }
                if (lvl.Text == "")
                {
                    MessageBox.Show("Bitte trage dein Level ein!");
                    return;
                }
                if (plr_class.Text == "")
                {
                    MessageBox.Show("Bitte trage deine Klasse ein!");
                    return;
                }
                if (plr_race.Text == "")
                {
                    MessageBox.Show("Bitte trage deine Rasse ein!");
                    return;
                }
                if (plr_armor.Text == "")
                {
                    MessageBox.Show("Bitte trage deinen Rüstungswert ein!");
                    return;
                }
                g_brust.Enabled = false;
                g_finger.Enabled = false;
                g_fuß.Enabled = false;
                g_gurt.Enabled = false;
                g_hals.Enabled = false;
                g_hand.Enabled = false;
                g_kopf.Enabled = false;
                g_schild.Enabled = false;
                g_schmuck.Enabled = false;
                g_waffe.Enabled = false;
                switch (class_)
                {
                    case "Magier":
                        //Rechnen.....
                        int def_ = GetResistance(TI(val_str.Text));
                        int def2_ = GetResistance(TI(val_ges.Text));
                        double min_dmg = GetAttackPower(TI(waffe_min.Text), TI(val_int.Text));
                        double max_dmg = GetAttackPower(TI(waffe_max.Text), TI(val_int.Text));
                        double life = GetLife(TI(val_aus.Text), 4, TI(lvl.Text));
                        double life_normal = life;
                        if (lifebonus)
                            life *= 1.25;
                        double lvl_ = 0;
                        if (lvl_op.Text != "" && lvl_op.Text != "0")
                            lvl_ = Convert.ToDouble(lvl_op.Text);
                        else
                            lvl_ = Convert.ToDouble(lvl.Text);
                        double crit = GetCrit(TI(val_luck.Text), (int)lvl_);
                        dmg_red = armor / TI(lvl.Text);
                        if (dmg_red > 10)
                            dmg_red = 10;
                        //Runden....
                        min_dmg = Math.Round(min_dmg, 0, MidpointRounding.ToEven);
                        max_dmg = Math.Round(max_dmg, 0, MidpointRounding.ToEven);
                        life = Math.Round(life, 0, MidpointRounding.ToEven);
                        crit = Math.Round(crit, 2, MidpointRounding.ToEven);
                        if (crit > 50)
                            crit = 50;
                        //Eintragen...
                        dmg_min.Text = min_dmg.ToString();
                        dmg_max.Text = max_dmg.ToString();
                        val_life.Text = life.ToString();
                        if (lifebonus)
                            points.SetToolTip(val_life, life_normal.ToString() + " + " + (life - life_normal).ToString());
                        else
                            points.SetToolTip(val_life, life_normal.ToString());
                        val_crit.Text = crit.ToString() + " %";
                        val_def.Text = def_.ToString();
                        val_def2.Text = def2_.ToString();
                        break;
                    case "Krieger":
                        //Rechnen...
                        def_ = GetResistance(TI(val_int.Text));
                        def2_ = GetResistance(TI(val_ges.Text));
                        min_dmg = GetAttackPower(TI(waffe_min.Text), TI(val_str.Text));
                        max_dmg = GetAttackPower(TI(waffe_max.Text), TI(val_str.Text));
                        life = GetLife(TI(val_life.Text), 10, TI(lvl.Text));
                        life_normal = life;
                        if (lifebonus)
                            life *= 1.25;
                        lvl_ = 0;
                        if (lvl_op.Text != "" && lvl_op.Text != "0")
                            lvl_ = Convert.ToDouble(lvl_op.Text);
                        else
                            lvl_ = Convert.ToDouble(lvl.Text);
                        crit = GetCrit(TI(val_luck.Text), (int)lvl_);
                        dmg_red = armor / TI(lvl.Text);
                        if (dmg_red > 50)
                            dmg_red = 50;
                        //Runden....
                        min_dmg = Math.Round(min_dmg, 0, MidpointRounding.ToEven);
                        max_dmg = Math.Round(max_dmg, 0, MidpointRounding.ToEven);
                        life = Math.Round(life, 0, MidpointRounding.ToEven);
                        crit = Math.Round(crit, 2, MidpointRounding.ToEven);
                        if (crit > 50)
                            crit = 50;
                        //Eintragen...
                        dmg_min.Text = min_dmg.ToString();
                        dmg_max.Text = max_dmg.ToString();
                        val_life.Text = life.ToString();
                        if (lifebonus)
                            points.SetToolTip(val_life, life_normal.ToString() + " + " + (life - life_normal).ToString());
                        else
                            points.SetToolTip(val_life, life_normal.ToString());
                        val_crit.Text = crit.ToString() + " %";
                        val_def.Text = def_.ToString();
                        val_def2.Text = def2_.ToString();
                        break;
                    case "Kundschaftler":
                        //Rechnen...
                        def_ = GetResistance(TI(val_int.Text));
                        def2_ = GetResistance(TI(val_str.Text));
                        min_dmg = GetAttackPower(TI(waffe_min.Text), TI(val_ges.Text));
                        max_dmg = GetAttackPower(TI(waffe_max.Text), TI(val_ges.Text));
                        life = GetLife(TI(val_life.Text), 10, TI(lvl.Text));
                        life_normal = life;
                        if (lifebonus)
                            life *= 1.25;
                        lvl_ = 0;
                        if (lvl_op.Text != "" && lvl_op.Text != "0")
                            lvl_ = Convert.ToDouble(lvl_op.Text);
                        else
                            lvl_ = Convert.ToDouble(lvl.Text);
                        crit = GetCrit(TI(val_luck.Text), (int)lvl_);
                        dmg_red = armor / TI(lvl.Text);
                        if (dmg_red > 25)
                            dmg_red = 25;
                        //Runden....
                        min_dmg = Math.Round(min_dmg, 0, MidpointRounding.ToEven);
                        max_dmg = Math.Round(max_dmg, 0, MidpointRounding.ToEven);
                        life = Math.Round(life, 0, MidpointRounding.ToEven);
                        crit = Math.Round(crit, 2, MidpointRounding.ToEven);
                        if (crit > 50)
                            crit = 50;
                        //Eintragen...
                        dmg_min.Text = min_dmg.ToString();
                        dmg_max.Text = max_dmg.ToString();
                        val_life.Text = life.ToString();
                        if (lifebonus)
                            points.SetToolTip(val_life, life_normal.ToString() + " + " + (life - life_normal).ToString());
                        else
                            points.SetToolTip(val_life, life_normal.ToString());
                        val_crit.Text = crit.ToString() + " %";
                        val_def.Text = def_.ToString();
                        val_def2.Text = def2_.ToString();
                        break;
                }
                UpdateTooltip();
                calculated = true;
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void AttributeInput()
        {
            this.Hide();
            this.Enabled = false;
            atr_input.Show(Owner);
            atr_input.btn_ok.Click += new EventHandler(btn_ok_Click);
            atr_input.btn_c.Click += new EventHandler(btn_c_Click);
			atr_input.load.Click += new EventHandler(load_Click);
        }
        void EquipHandler(int atr1, int atr2, int atr3, string atr1_, string atr2_, string atr3_)
        {
            try
            {
                switch (atr1_)
                {
                    case "Stärke":
                        AddPoints(atr1, 0, 0, 0, 0);
                        AddEquipPoints(atr1, 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, atr1, 0, 0, 0);
                        AddEquipPoints(0, atr1, 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, atr1, 0, 0);
                        AddEquipPoints(0, 0, atr1, 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, atr1, 0);
                        AddEquipPoints(0, 0, 0, atr1, 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, atr1);
                        AddEquipPoints(0, 0, 0, 0, atr1);
                        break;
                    case "Alle Attribute":
                        AddPoints(atr1, atr1, atr1, atr1, atr1);
                        AddEquipPoints(atr1, atr1, atr1, atr1, atr1);
                        break;
                }
                switch (atr2_)
                {
                    case "Stärke":
                        AddPoints(atr2, 0, 0, 0, 0);
                        AddEquipPoints(atr2, 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, atr2, 0, 0, 0);
                        AddEquipPoints(0, atr2, 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, atr2, 0, 0);
                        AddEquipPoints(0, 0, atr2, 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, atr2, 0);
                        AddEquipPoints(0, 0, 0, atr2, 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, atr2);
                        AddEquipPoints(0, 0, 0, 0, atr2);
                        break;
                    case "Alle Attribute":
                        AddPoints(atr2, atr2, atr2, atr2, atr2);
                        AddEquipPoints(atr2, atr2, atr2, atr2, atr2);
                        break;
                }
                switch (atr3_)
                {
                    case "Stärke":
                        AddPoints(atr3, 0, 0, 0, 0);
                        AddEquipPoints(atr3, 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, atr3, 0, 0, 0);
                        AddEquipPoints(0, atr3, 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, atr3, 0, 0);
                        AddEquipPoints(0, 0, atr3, 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, atr3, 0);
                        AddEquipPoints(0, 0, 0, atr3, 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, atr3);
                        AddEquipPoints(0, 0, 0, 0, atr3);
                        break;
                    case "Alle Attribute":
                        AddPoints(atr3, atr3, atr3, atr3, atr3);
                        AddEquipPoints(atr3, atr3, atr3, atr3, atr3);
                        break;
                }
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void EquipHandler2(int atr1, int atr2, int atr3, string atr1_, string atr2_, string atr3_)
        {
            try
            {
                switch (atr1_)
                {
                    case "Stärke":
                        AddPoints(-atr1, 0, 0, 0, 0);
                        AddEquipPoints(-atr1, 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, -atr1, 0, 0, 0);
                        AddEquipPoints(0, -atr1, 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, -atr1, 0, 0);
                        AddEquipPoints(0, 0, -atr1, 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, -atr1, 0);
                        AddEquipPoints(0, 0, 0, -atr1, 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, -atr1);
                        AddEquipPoints(0, 0, 0, 0, -atr1);
                        break;
                    case "Alle Attribute":
                        AddPoints(-atr1, -atr1, -atr1, -atr1, -atr1);
                        AddEquipPoints(-atr1, -atr1, -atr1, -atr1, -atr1);
                        break;
                }
                switch (atr2_)
                {
                    case "Stärke":
                        AddPoints(-atr2, 0, 0, 0, 0);
                        AddEquipPoints(-atr2, 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, -atr2, 0, 0, 0);
                        AddEquipPoints(0, -atr2, 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, -atr2, 0, 0);
                        AddEquipPoints(0, 0, -atr2, 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, -atr2, 0);
                        AddEquipPoints(0, 0, 0, -atr2, 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, -atr2);
                        AddEquipPoints(0, 0, 0, 0, -atr2);
                        break;
                    case "Alle Attribute":
                        AddPoints(-atr2, -atr2, -atr2, -atr2, -atr2);
                        AddEquipPoints(-atr2, -atr2, -atr2, -atr2, -atr2);
                        break;
                }
                switch (atr3_)
                {
                    case "Stärke":
                        AddPoints(-atr3, 0, 0, 0, 0);
                        AddEquipPoints(-atr3, 0, 0, 0, 0);
                        break;
                    case "Geschick":
                        AddPoints(0, -atr3, 0, 0, 0);
                        AddEquipPoints(0, -atr3, 0, 0, 0);
                        break;
                    case "Intelligenz":
                        AddPoints(0, 0, -atr3, 0, 0);
                        AddEquipPoints(0, 0, -atr3, 0, 0);
                        break;
                    case "Ausdauer":
                        AddPoints(0, 0, 0, -atr3, 0);
                        AddEquipPoints(0, 0, 0, -atr3, 0);
                        break;
                    case "Glück":
                        AddPoints(0, 0, 0, 0, -atr3);
                        AddEquipPoints(0, 0, 0, 0, -atr3);
                        break;
                    case "Alle Attribute":
                        AddPoints(-atr3, -atr3, -atr3, -atr3, -atr3);
                        AddEquipPoints(-atr3, -atr3, -atr3, -atr3, -atr3);
                        break;
                }
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void Save()
        {
            try
            {
                //Attribute
                int str = TI(val_str.Text);
                int ges = TI(val_ges.Text);
                int int_ = TI(val_int.Text);
                int aus = TI(val_aus.Text);
                int luck = TI(val_luck.Text);
                int arm = TI(plr_armor.Text);
                //Level/Rasse/Klasse
                string class_ = plr_class.Text;
                string race = plr_race.Text;
                int lvl_ = TI(lvl.Text);
                int lvl_op_ = 0;
                if (lvl_op.Text != "")
                    lvl_op_ = TI(lvl_op.Text);
                //Equip Attribute
                int skopf_1 = TI(kopf__1.Text);
                int skopf_2 = TI(kopf__2.Text);
                int skopf_3 = TI(kopf__3.Text);
                string akopf_1 = kopf_1.Text;
                string akopf_2 = kopf_2.Text;
                string akopf_3 = kopf_3.Text;
                int sbrust_1 = TI(brust__1.Text);
                int sbrust_2 = TI(brust__2.Text);
                int sbrust_3 = TI(brust__3.Text);
                string abrust_1 = brust_1.Text;
                string abrust_2 = brust_2.Text;
                string abrust_3 = brust_3.Text;
                int shand_1 = TI(hand__1.Text);
                int shand_2 = TI(hand__2.Text);
                int shand_3 = TI(hand__3.Text);
                string ahand_1 = hand_1.Text;
                string ahand_2 = hand_2.Text;
                string ahand_3 = hand_3.Text;
                int sfüße_1 = TI(füße__1.Text);
                int sfüße_2 = TI(füße__2.Text);
                int sfüße_3 = TI(füße__3.Text);
                string afüße_1 = füße_1.Text;
                string afüße_2 = füße_2.Text;
                string afüße_3 = füße_3.Text;
                int shals_1 = TI(hals__1.Text);
                int shals_2 = TI(hals__2.Text);
                int shals_3 = TI(hals__3.Text);
                string ahals_1 = hals_1.Text;
                string ahals_2 = hals_2.Text;
                string ahals_3 = hals_3.Text;
                int sgürtel_1 = TI(gürtel__1.Text);
                int sgürtel_2 = TI(gürtel__2.Text);
                int sgürtel_3 = TI(gürtel__3.Text);
                string agürtel_1 = gürtel_1.Text;
                string agürtel_2 = gürtel_2.Text;
                string agürtel_3 = gürtel_3.Text;
                int sfinger_1 = TI(finger__1.Text);
                int sfinger_2 = TI(finger__2.Text);
                int sfinger_3 = TI(finger__3.Text);
                string afinger_1 = finger_1.Text;
                string afinger_2 = finger_2.Text;
                string afinger_3 = finger_3.Text;
                int sschmuck_1 = TI(schmuck__1.Text);
                int sschmuck_2 = TI(schmuck__2.Text);
                int sschmuck_3 = TI(schmuck__3.Text);
                string aschmuck_1 = schmuck_1.Text;
                string aschmuck_2 = schmuck_2.Text;
                string aschmuck_3 = schmuck_3.Text;
                int smin;
                int smax;
                if (waffe_min.Text != "min Dmg" || waffe_max.Text != "max Dmg")
                {
                    smin = TI(waffe_min.Text);
                    smax = TI(waffe_max.Text);
                }
                else
                {
                    smin = 0;
                    smax = 0;
                }
                int swaffe_1 = TI(waffe__1.Text);
                int swaffe_2 = TI(waffe__2.Text);
                int swaffe_3 = TI(waffe__3.Text);
                string awaffe_1 = waffe_1.Text;
                string awaffe_2 = waffe_2.Text;
                string awaffe_3 = waffe_3.Text;
                int sschild_1 = TI(schild__1.Text);
                int sschild_2 = TI(schild__2.Text);
                int sschild_3 = TI(schild__3.Text);
                string aschild_1 = schild_1.Text;
                string aschild_2 = schild_2.Text;
                string aschild_3 = schild_3.Text;
                StreamWriter write = new StreamWriter(d_save.FileName, false, Encoding.UTF8);
                write.WriteLine("[STATS]");
                write.WriteLine(str);
                write.WriteLine(ges);
                write.WriteLine(int_);
                write.WriteLine(aus);
                write.WriteLine(luck);
                write.WriteLine(arm);
                write.WriteLine("[CLASS & LEVEL]");
                write.WriteLine(class_);
                write.WriteLine(race);
                write.WriteLine(lvl_);
                write.WriteLine(lvl_op_);
                write.WriteLine("[EQUIP ATTRIBUTES]");
                write.WriteLine("[HEAD]");
                write.WriteLine(skopf_1);
                write.WriteLine(skopf_2);
                write.WriteLine(skopf_3);
                write.WriteLine(akopf_1);
                write.WriteLine(akopf_2);
                write.WriteLine(akopf_3);
                write.WriteLine("[BREAST]");
                write.WriteLine(sbrust_1);
                write.WriteLine(sbrust_2);
                write.WriteLine(sbrust_3);
                write.WriteLine(abrust_1);
                write.WriteLine(abrust_2);
                write.WriteLine(abrust_3);
                write.WriteLine("[HANDS]");
                write.WriteLine(shand_1);
                write.WriteLine(shand_2);
                write.WriteLine(shand_3);
                write.WriteLine(ahand_1);
                write.WriteLine(ahand_2);
                write.WriteLine(ahand_3);
                write.WriteLine("[FEET]");
                write.WriteLine(sfüße_1);
                write.WriteLine(sfüße_2);
                write.WriteLine(sfüße_3);
                write.WriteLine(afüße_1);
                write.WriteLine(afüße_2);
                write.WriteLine(afüße_3);
                write.WriteLine("[NECK]");
                write.WriteLine(shals_1);
                write.WriteLine(shals_2);
                write.WriteLine(shals_3);
                write.WriteLine(ahals_1);
                write.WriteLine(ahals_2);
                write.WriteLine(ahals_3);
                write.WriteLine("[BELT]");
                write.WriteLine(sgürtel_1);
                write.WriteLine(sgürtel_2);
                write.WriteLine(sgürtel_3);
                write.WriteLine(agürtel_1);
                write.WriteLine(agürtel_2);
                write.WriteLine(agürtel_3);
                write.WriteLine("[FINGER]");
                write.WriteLine(sfinger_1);
                write.WriteLine(sfinger_2);
                write.WriteLine(sfinger_3);
                write.WriteLine(afinger_1);
                write.WriteLine(afinger_2);
                write.WriteLine(afinger_3);
                write.WriteLine("[TRINKET]");
                write.WriteLine(sschmuck_1);
                write.WriteLine(sschmuck_2);
                write.WriteLine(sschmuck_3);
                write.WriteLine(aschmuck_1);
                write.WriteLine(aschmuck_2);
                write.WriteLine(aschmuck_3);
                write.WriteLine("[WEAPON]");
                write.WriteLine(swaffe_1);
                write.WriteLine(swaffe_2);
                write.WriteLine(swaffe_3);
                write.WriteLine(awaffe_1);
                write.WriteLine(awaffe_2);
                write.WriteLine(awaffe_3);
                write.WriteLine(smin);
                write.WriteLine(smax);
                write.WriteLine("[SHIELD]");
                write.WriteLine(sschild_1);
                write.WriteLine(sschild_2);
                write.WriteLine(sschild_3);
                write.WriteLine(aschild_1);
                write.WriteLine(aschild_2);
                write.WriteLine(aschild_3);
                write.WriteLine("[BASE POINTS]");
                write.WriteLine(base_str.ToString());
                write.WriteLine(base_ges.ToString());
                write.WriteLine(base_int.ToString());
                write.WriteLine(base_aus.ToString());
                write.WriteLine(base_luck.ToString());
                write.WriteLine("[EQUIP POINTS]");
                write.WriteLine(equip_str.ToString());
                write.WriteLine(equip_ges.ToString());
                write.WriteLine(equip_int.ToString());
                write.WriteLine(equip_aus.ToString());
                write.WriteLine(equip_luck.ToString());
                write.WriteLine("[END]");
                write.Close();
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        void Open(string path)
        {
            try
            {
                StreamReader read = new StreamReader(path, Encoding.UTF8);
                if (read.ReadLine() != "[STATS]")
                    throw new FormatException("Die Datei hat das falsche Format");
                //Attribute
                val_str.Text = read.ReadLine();
                val_ges.Text = read.ReadLine();
                val_int.Text = read.ReadLine();
                val_aus.Text = read.ReadLine();
                val_luck.Text = read.ReadLine();
                plr_armor.Text = read.ReadLine();
                //Level/Rasse/Klasse
                if (read.ReadLine() != "[CLASS & LEVEL]")
                    throw new FormatException("Die Datei hat das falsche Format");
                string class_ = read.ReadLine();
                plr_race.Text = read.ReadLine();
                if (class_ == "Krieger")
                    plr_class.SelectedIndex = 0;
                else if (class_ == "Magier")
                    plr_class.SelectedIndex = 1;
                else if (class_ == "Kundschaftler")
                    plr_class.SelectedIndex = 2;
                lvl.Text = read.ReadLine();
                lvl_op.Text = read.ReadLine();
                //Equip Attribute
                if (read.ReadLine() != "[EQUIP ATTRIBUTES]")
                    throw new FormatException("Die Datei hat das falsche Format");
                if (read.ReadLine() != "[HEAD]")
                    throw new FormatException("Die Datei hat das falsche Format");
                kopf__1.Text = read.ReadLine();
                kopf__2.Text = read.ReadLine();
                kopf__3.Text = read.ReadLine();
                kopf_1.Text = read.ReadLine();
                kopf_2.Text = read.ReadLine();
                kopf_3.Text = read.ReadLine();
                if (read.ReadLine() != "[BREAST]")
                    throw new FormatException("Die Datei hat das falsche Format");
                brust__1.Text = read.ReadLine();
                brust__2.Text = read.ReadLine();
                brust__3.Text = read.ReadLine();
                brust_1.Text = read.ReadLine();
                brust_2.Text = read.ReadLine();
                brust_3.Text = read.ReadLine();
                if (read.ReadLine() != "[HANDS]")
                    throw new FormatException("Die Datei hat das falsche Format");
                hand__1.Text = read.ReadLine();
                hand__2.Text = read.ReadLine();
                hand__3.Text = read.ReadLine();
                hand_1.Text = read.ReadLine();
                hand_2.Text = read.ReadLine();
                hand_3.Text = read.ReadLine();
                if (read.ReadLine() != "[FEET]")
                    throw new FormatException("Die Datei hat das falsche Format");
                füße__1.Text = read.ReadLine();
                füße__2.Text = read.ReadLine();
                füße__3.Text = read.ReadLine();
                füße_1.Text = read.ReadLine();
                füße_2.Text = read.ReadLine();
                füße_3.Text = read.ReadLine();
                if (read.ReadLine() != "[NECK]")
                    throw new FormatException("Die Datei hat das falsche Format");
                hals__1.Text = read.ReadLine();
                hals__2.Text = read.ReadLine();
                hals__3.Text = read.ReadLine();
                hals_1.Text = read.ReadLine();
                hals_2.Text = read.ReadLine();
                hals_3.Text = read.ReadLine();
                if (read.ReadLine() != "[BELT]")
                    throw new FormatException("Die Datei hat das falsche Format");
                gürtel__1.Text = read.ReadLine();
                gürtel__2.Text = read.ReadLine();
                gürtel__3.Text = read.ReadLine();
                gürtel_1.Text = read.ReadLine();
                gürtel_2.Text = read.ReadLine();
                gürtel_3.Text = read.ReadLine();
                if (read.ReadLine() != "[FINGER]")
                    throw new FormatException("Die Datei hat das falsche Format");
                finger__1.Text = read.ReadLine();
                finger__2.Text = read.ReadLine();
                finger__3.Text = read.ReadLine();
                finger_1.Text = read.ReadLine();
                finger_2.Text = read.ReadLine();
                finger_3.Text = read.ReadLine();
                if (read.ReadLine() != "[TRINKET]")
                    throw new FormatException("Die Datei hat das falsche Format");
                schmuck__1.Text = read.ReadLine();
                schmuck__2.Text = read.ReadLine();
                schmuck__3.Text = read.ReadLine();
                schmuck_1.Text = read.ReadLine();
                schmuck_2.Text = read.ReadLine();
                schmuck_3.Text = read.ReadLine();
                if (read.ReadLine() != "[WEAPON]")
                    throw new FormatException("Die Datei hat das falsche Format");
                waffe__1.Text = read.ReadLine();
                waffe__2.Text = read.ReadLine();
                waffe__3.Text = read.ReadLine();
                waffe_1.Text = read.ReadLine();
                waffe_2.Text = read.ReadLine();
                waffe_3.Text = read.ReadLine();
                waffe_min.Text = read.ReadLine();
                waffe_max.Text = read.ReadLine();
                if (read.ReadLine() != "[SHIELD]")
                    throw new FormatException("Die Datei hat das falsche Format");
                schild__1.Text = read.ReadLine();
                schild__2.Text = read.ReadLine();
                schild__3.Text = read.ReadLine();
                schild_1.Text = read.ReadLine();
                schild_2.Text = read.ReadLine();
                schild_3.Text = read.ReadLine();
                if (read.ReadLine() != "[BASE POINTS]")
                    throw new FormatException("Die Datei hat das falsche Format");
                base_str = TI(read.ReadLine());
                base_ges = TI(read.ReadLine());
                base_int = TI(read.ReadLine());
                base_aus = TI(read.ReadLine());
                base_luck = TI(read.ReadLine());
                if (read.ReadLine() != "[EQUIP POINTS]")
                    throw new FormatException("Die Datei hat das falsche Format");
                equip_str = TI(read.ReadLine());
                equip_ges = TI(read.ReadLine());
                equip_int = TI(read.ReadLine());
                equip_aus = TI(read.ReadLine());
                equip_luck = TI(read.ReadLine());
                read.Close();
                g_brust.Enabled = false;
                g_finger.Enabled = false;
                g_fuß.Enabled = false;
                g_gurt.Enabled = false;
                g_hals.Enabled = false;
                g_hand.Enabled = false;
                g_kopf.Enabled = false;
                g_schild.Enabled = false;
                g_schmuck.Enabled = false;
                g_waffe.Enabled = false;
                lvl.Enabled = false;
                lvl_op.Enabled = false;
                plr_armor.Enabled = false;
                armor = TI(plr_armor.Text);
                CalculateStats(plr_class.Text);
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
                MessageBox.Show(e.Message, e.Source, MessageBoxButtons.OK, MessageBoxIcon.Error);
                object sender = new object();
                EventArgs ea = new EventArgs();
                reset_items_Click(sender, ea);
                button3_Click(sender, ea);
                plr_class.SelectedIndex = -1;
                plr_race.SelectedIndex = -1;
                plr_class.Enabled = true;
                plr_race.Enabled = true;
                equip_str = 0;
                equip_aus = 0;
                equip_ges = 0;
                equip_int = 0;
                equip_luck = 0;
                base_aus = 0;
                base_ges = 0;
                base_int = 0;
                base_luck = 0;
                base_str = 0;
                val_str.Text = "0";
                val_ges.Text = "0";
                val_int.Text = "0";
                val_aus.Text = "0";
                val_luck.Text = "0";
            }
        }
		public void LoadChar(string info)
		{
			atr_input.processbar.Value += 5;
			atr_input.process.Text = "Sorting information...";
			string[] data2 = info.Split(';');
			string[] data = data2[0].Split('/');
			data2 = new string[] { data2[1], data2[2] };
			data = Mgr.GetMergedArray(data, data2);
			atr_input.processbar.Value += 5;
			DateTime loadingtime = StampToTime(TI(data[(int)CacheFormat.TIMENOW]));
			atr_input.loadingtime.Text += loadingtime.ToString();
			atr_input.processbar.Value += 5;
			atr_input.description.Text += data[(int)CacheFormat.CHARDESCRIPTION] + "\r\n";
			atr_input.description.Text = atr_input.description.Text.Replace("#", "\r\n");
			atr_input.processbar.Value += 5;
			atr_input.accid.Text = data[(int)CacheFormat.ACCOUNTID];
			atr_input.processbar.Value += 5;
			atr_input.process.Text = "Done!";
			atr_input.processbar.Value = 100;
			
		}
        #endregion

        #region questrechner
        void CalcQuests()
        {
            try
            {
                opt_quest.Text = "";
                double q1_l = Convert.ToDouble(q1_lenght.Text);
                double q1_g = Convert.ToDouble(q1_gold.Text);
                double q1_e = Convert.ToDouble(q1_ep.Text);
                double gpm1 = q1_g / q1_l;
                double epm1 = q1_e / q1_l;
                double q2_l = Convert.ToDouble(q2_lenght.Text);
                double q2_g = Convert.ToDouble(q2_gold.Text);
                double q2_e = Convert.ToDouble(q2_ep.Text);
                double gpm2 = q2_g / q2_l;
                double epm2 = q2_e / q2_l;
                double q3_l = Convert.ToDouble(q3_lenght.Text);
                double q3_g = Convert.ToDouble(q3_gold.Text);
                double q3_e = Convert.ToDouble(q3_ep.Text);
                double gpm3 = q3_g / q3_l;
                double epm3 = q3_e / q3_l;
                q1_tb.Text = gpm1.ToString();
                q2_tb.Text = gpm2.ToString();
                q3_tb.Text = gpm3.ToString();
                q1_tb2.Text = epm1.ToString();
                q2_tb2.Text = epm2.ToString();
                q3_tb2.Text = epm3.ToString();
                double[] gpm_max = new double[3];
                gpm_max[0] = gpm1;
                gpm_max[1] = gpm2;
                gpm_max[2] = gpm3;
                double[] epm_max = new double[3];
                epm_max[0] = epm1;
                epm_max[1] = epm2;
                epm_max[2] = epm3;
                if (q1_tb.Text == "+unendlich" || q1_tb.Text == "n. def.")
                    q1_tb.Text = "0";
                if (q2_tb.Text == "+unendlich" || q2_tb.Text == "n. def.")
                    q2_tb.Text = "0";
                if (q3_tb.Text == "+unendlich" || q3_tb.Text == "n. def.")
                    q3_tb.Text = "0";
                if (q1_tb2.Text == "+unendlich" || q1_tb2.Text == "n. def.")
                    q1_tb2.Text = "0";
                if (q2_tb2.Text == "+unendlich" || q2_tb2.Text == "n. def.")
                    q2_tb2.Text = "0";
                if (q3_tb2.Text == "+unendlich" || q3_tb2.Text == "n. def.")
                    q3_tb2.Text = "0";
                if (max_gold.Checked)
                {
                    if (q1_tb.Text == gpm_max.Max().ToString() && q1_tb.Text != "0")
                        opt_quest.Text = "Quest 1";
                    if (q2_tb.Text == gpm_max.Max().ToString() && q2_tb.Text != "0")
                        opt_quest.Text = "Quest 2";
                    if (q3_tb.Text == gpm_max.Max().ToString() && q3_tb.Text != "0")
                        opt_quest.Text = "Quest 3";
                }
                else if (max_ep.Checked)
                {
                    if (q1_tb2.Text == epm_max.Max().ToString() && q1_tb2.Text != "0")
                        opt_quest.Text = "Quest 1";
                    if (q2_tb2.Text == epm_max.Max().ToString() && q2_tb2.Text != "0")
                        opt_quest.Text = "Quest 2";
                    if (q3_tb2.Text == epm_max.Max().ToString() && q3_tb2.Text != "0")
                        opt_quest.Text = "Quest 3";
                }
                else if (max_nix.Checked)
                {
                    if (q1_tb.Text != gpm_max.Max().ToString() && q1_tb2.Text != epm_max.Max().ToString() && q1_tb.Text != "0" && q1_tb2.Text != "0" /*&& q1_tb.Text != gpm_max.Min().ToString() && q1_tb2.Text != epm_max.Min().ToString()*/)
                        opt_quest.Text = "Quest 1";
                    if (q2_tb.Text != gpm_max.Max().ToString() && q2_tb2.Text != epm_max.Max().ToString() && q2_tb.Text != "0" && q2_tb2.Text != "0" /*&& q2_tb.Text != gpm_max.Min().ToString() && q2_tb2.Text != epm_max.Min().ToString()*/)
                        opt_quest.Text = "Quest 2";
                    if (q3_tb.Text != gpm_max.Max().ToString() && q3_tb2.Text != epm_max.Max().ToString() && q3_tb.Text != "0" && q3_tb2.Text != "0" /*&& q3_tb.Text != gpm_max.Min().ToString() && q3_tb2.Text != epm_max.Min().ToString()*/)
                        opt_quest.Text = "Quest 3";
                }
                if (opt_quest.Text == "")
                    opt_quest.Text = "n/A";
            }
            catch (Exception e)
            {
                Program.LogWrite(e);
            }
        }
        #endregion

        #region kampfrechner
        private void btn_getstats_Click(object sender, EventArgs e)
        {
            if (waffe_min.Text == "min Dmg" || waffe_max.Text == "max Dmg")
            {
                MessageBox.Show("Bitte trage den Waffenschaden ein!");
                return;
            }
            if (lvl.Text == "")
            {
                MessageBox.Show("Bitte trage dein Level ein!");
                return;
            }
            if (plr_class.Text == "")
            {
                MessageBox.Show("Bitte trage deine Klasse ein!");
                return;
            }
            if (plr_race.Text == "")
            {
                MessageBox.Show("Bitte trage deine Rasse ein!");
                return;
            }
            CalculateStats(plr_class.Text);
            self_str.Text = val_str.Text;
            self_ges.Text = val_ges.Text;
            self_int.Text = val_int.Text;
            self_aus.Text = val_aus.Text;
            self_luck.Text = val_luck.Text;
            self_life.Text = val_life.Text;
            int d = (TI(dmg_min.Text) + TI(dmg_max.Text)) / 2;
            self_dmg.Text = dmg_min.Text + " - " + dmg_max.Text + " (~" + d.ToString() + ")";
            self_crit.Text = val_crit.Text;
            self_def1.Text = val_def.Text;
            self_def2.Text = val_def2.Text;
            self_def1l.Text = def.Text;
            self_def2l.Text = def2.Text;
            self_str.Enabled = false;
            self_ges.Enabled = false;
            self_int.Enabled = false;
            self_aus.Enabled = false;
            self_luck.Enabled = false;
            self_mindmg.Text = waffe_min.Text;
            self_maxdmg.Text = waffe_max.Text;
            self_mindmg.Enabled = false;
            self_maxdmg.Enabled = false;
            self_armor.Text = plr_armor.Text;
            self_armor.Enabled = false;
            self_class.SelectedIndex = plr_class.SelectedIndex;
            self_class.Enabled = false;
            self_dmgred.Text = "- " + dmg_red.ToString() + "%";
            self_hpt.Text = val_life.Text + "/" + val_life.Text;
            //self_hp.Maximum = TI(val_life.Text);
            //self_hp.Value = TI(val_life.Text);
        }

        private void self_str_TextChanged(object sender, EventArgs e)
        {
            EnabledMask();
        }
        private void enemy_class_SelectedIndexChanged(object sender, EventArgs e)
        {
            EnabledMask();
        }
        private void tab_Selecting(object sender, TabControlCancelEventArgs e)
        {
            EnabledMask();
        }
        void EnabledMask()
        {
            if (enemy_armor.Text != "" && enemy_aus.Text != "" && enemy_class.SelectedIndex != -1 && enemy_ges.Text != "" && enemy_int.Text != "" && enemy_luck.Text != "" && enemy_maxdmg.Text != "" && enemy_mindmg.Text != "" && enemy_str.Text != "" && self_lvl.Text != "" && enemy_lvl.Text != "")
            {
                enemy_ok.Enabled = true;
            }
            else
                enemy_ok.Enabled = false;
            if (self_armor.Text != "" && self_aus.Text != "" && self_class.SelectedIndex != -1 && self_ges.Text != "" && self_int.Text != "" && self_luck.Text != "" && self_maxdmg.Text != "" && self_mindmg.Text != "" && self_str.Text != "" && self_lvl.Text != "" && enemy_lvl.Text != "")
            {
                self_ok.Enabled = true;
                btn_getstats.Enabled = calculated;
            }
            else
            {
                self_ok.Enabled = false;
                btn_getstats.Enabled = calculated;
            }
        }
        private void enemy_ok_Click(object sender, EventArgs e)
        {
            try
            {
                /*if (waffe_min.Text == "min Dmg" || waffe_max.Text == "max Dmg")
                {
                    MessageBox.Show("Bitte trage den Waffenschaden ein!");
                    return;
                }
                if (lvl.Text == "")
                {
                    MessageBox.Show("Bitte trage dein Level ein!");
                    return;
                }
                if (plr_class.Text == "")
                {
                    MessageBox.Show("Bitte trage deine Klasse ein!");
                    return;
                }
                if (plr_race.Text == "")
                {
                    MessageBox.Show("Bitte trage deine Rasse ein!");
                    return;
                }
                if (plr_armor.Text == "")
                {
                    MessageBox.Show("Bitte trage deinen Rüstungswert ein!");
                    return;
                }*/
                string class_ = enemy_class.Text;
                switch (class_)
                {
                    case "Magier":
                        //Rechnen.....
                        int def_ = TI(enemy_str.Text) / 2;
                        int def2_ = TI(enemy_ges.Text) / 2;
                        double min_dmg = Convert.ToDouble(enemy_mindmg.Text) * (1 + Convert.ToDouble(enemy_int.Text) / 10);
                        double max_dmg = Convert.ToDouble(enemy_maxdmg.Text) * (1 + Convert.ToDouble(enemy_int.Text) / 10);
                        int dmg = ((int)min_dmg + (int)max_dmg) / 2;
                        double life = Convert.ToDouble(enemy_aus.Text) * 4 * (0.5 + Convert.ToDouble(enemy_lvl.Text) / 2);
                        double lvl_ = Convert.ToDouble(self_lvl.Text);
                        double crit = Convert.ToDouble(enemy_luck.Text) * 25 / (lvl_ * 10);
                        int arm = TI(enemy_armor.Text);
                        dmg_red = arm / TI(enemy_lvl.Text);
                        if (dmg_red > 10)
                            dmg_red = 10;
                        //Runden....
                        min_dmg = Math.Round(min_dmg, 0, MidpointRounding.ToEven);
                        max_dmg = Math.Round(max_dmg, 0, MidpointRounding.ToEven);
                        life = Math.Round(life, 0, MidpointRounding.ToEven);
                        crit = Math.Round(crit, 2, MidpointRounding.ToEven);
                        if (crit > 50)
                            crit = 50;
                        //Eintragen...
                        enemy_dmg.Text = min_dmg.ToString() + "-" + max_dmg.ToString() + " (~" + dmg.ToString() + ")";
                        enemy_life.Text = life.ToString();
                        enemy_crit.Text = crit.ToString() + " %";
                        enemy_def.Text = def_.ToString();
                        enemy_def2.Text = def2_.ToString();
                        e_def.Text = "Verteidigung:";
                        e_def2.Text = "Ausweichen:";
                        enemy_hpt.Text = enemy_life.Text + "/" + enemy_life.Text;
                        //enemy_hp.Maximum = TI(enemy_life.Text);
                        //enemy_hp.Value = TI(enemy_life.Text);
                        enemy_dmgred.Text = dmg_red.ToString() + "%";
                        break;
                    case "Krieger":
                        //Rechnen...
                        def_ = TI(enemy_int.Text) / 2;
                        def2_ = TI(enemy_ges.Text) / 2;
                        min_dmg = Convert.ToDouble(enemy_mindmg.Text) * (1 + Convert.ToDouble(enemy_str.Text) / 10);
                        max_dmg = Convert.ToDouble(enemy_maxdmg.Text) * (1 + Convert.ToDouble(enemy_str.Text) / 10);
                        dmg = ((int)min_dmg + (int)max_dmg) / 2;
                        life = Convert.ToDouble(enemy_aus.Text) * 10 * (0.5 + Convert.ToDouble(enemy_lvl.Text) / 2);
                        lvl_ = Convert.ToDouble(self_lvl.Text);
                        crit = Convert.ToDouble(enemy_luck.Text) * 25 / (lvl_ * 10);
                        arm = TI(enemy_armor.Text);
                        dmg_red = arm / TI(enemy_lvl.Text);
                        if (dmg_red > 50)
                            dmg_red = 50;
                        //Runden....
                        min_dmg = Math.Round(min_dmg, 0, MidpointRounding.ToEven);
                        max_dmg = Math.Round(max_dmg, 0, MidpointRounding.ToEven);
                        life = Math.Round(life, 0, MidpointRounding.ToEven);
                        crit = Math.Round(crit, 2, MidpointRounding.ToEven);
                        if (crit > 50)
                            crit = 50;
                        //Eintragen...
                        enemy_dmg.Text = min_dmg.ToString() + "-" + max_dmg.ToString() + " (~" + dmg.ToString() + ")";
                        enemy_life.Text = life.ToString();
                        enemy_crit.Text = crit.ToString() + " %";
                        enemy_def.Text = def_.ToString();
                        enemy_def2.Text = def2_.ToString();
                        e_def.Text = "Widerstand:";
                        e_def2.Text = "Ausweichen:";
                        enemy_hpt.Text = enemy_life.Text + "/" + enemy_life.Text;
                        //enemy_hp.Maximum = TI(enemy_life.Text);
                        //enemy_hp.Value = TI(enemy_life.Text);
                        enemy_dmgred.Text = dmg_red.ToString() + "%";
                        break;
                    case "Kundschaftler":
                        //Rechnen...
                        def_ = TI(enemy_int.Text) / 2;
                        def2_ = TI(enemy_str.Text) / 2;
                        min_dmg = Convert.ToDouble(enemy_mindmg.Text) * (1 + Convert.ToDouble(enemy_ges.Text) / 10);
                        max_dmg = Convert.ToDouble(enemy_maxdmg.Text) * (1 + Convert.ToDouble(enemy_ges.Text) / 10);
                        dmg = ((int)min_dmg + (int)max_dmg) / 2;
                        life = Convert.ToDouble(enemy_aus.Text) * 8 * (0.5 + Convert.ToDouble(enemy_lvl.Text) / 2);
                        lvl_ = Convert.ToDouble(self_lvl.Text);
                        crit = Convert.ToDouble(enemy_luck.Text) * 25 / (lvl_ * 10);
                        arm = TI(enemy_armor.Text);
                        dmg_red = arm / TI(enemy_lvl.Text);
                        if (dmg_red > 25)
                            dmg_red = 25;
                        //Runden....
                        min_dmg = Math.Round(min_dmg, 0, MidpointRounding.ToEven);
                        max_dmg = Math.Round(max_dmg, 0, MidpointRounding.ToEven);
                        life = Math.Round(life, 0, MidpointRounding.ToEven);
                        crit = Math.Round(crit, 2, MidpointRounding.ToEven);
                        if (crit > 50)
                            crit = 50;
                        //Eintragen...
                        enemy_dmg.Text = min_dmg.ToString() + "-" + max_dmg.ToString() + " (~" + dmg.ToString() + ")";
                        enemy_life.Text = life.ToString();
                        enemy_crit.Text = crit.ToString() + " %";
                        enemy_def.Text = def_.ToString();
                        enemy_def2.Text = def2_.ToString();
                        e_def.Text = "Widerstand:";
                        e_def2.Text = "Verteidigung:";
                        enemy_hpt.Text = enemy_life.Text + "/" + enemy_life.Text;
                        //enemy_hp.Maximum = TI(enemy_life.Text);
                        //enemy_hp.Value = TI(enemy_life.Text);
                        enemy_dmgred.Text = dmg_red.ToString() + "%";
                        break;
                }
            }
            catch (Exception ex)
            {
                Program.LogWrite(ex);
            }
        }

        void Sim()
        {
            wait.Stop();
            float li = 10000.0f;
            Random dmg = new Random();
            int x = dmg.Next(0, 1000);
            BattleLogWrite("\r\n\r\nDu schlägst deinen Gegner und verursachst " + x.ToString() + " Schaden.", true);
            self_battle.Select((self_battle.Text.Length - 9 - x.ToString().Length), x.ToString().Length);
            self_battle.SelectionColor = Color.Red;
            //self_battle.SelectionFont = 
            float enemy_newwidth = (((float)x / li) * 314.0f);
            if (enemy_lifebar.Size.Width >= enemy_newwidth)
                enemy_lifebar.Size = new Size((int)Math.Round(enemy_lifebar.Size.Width - enemy_newwidth), enemy_lifebar.Size.Height);
            else
            {
                enemy_lifebar.Size = new Size(1,enemy_lifebar.Size.Height);
                BattleLogWrite("\r\nDein Gegner stirbt", true);
                wait.Stop();
                return;
            }
            x = dmg.Next(0, 1000);
            BattleLogWrite("\r\nDein Gegner schlägt dich und verursacht " + x.ToString() + " Schaden.\r\n", false);
            float self_newwidth = (((float)x / li) * 314.0f);
            if (self_lifebar.Size.Width >= self_newwidth)
                self_lifebar.Size = new Size((int)Math.Round(self_lifebar.Size.Width - self_newwidth), self_lifebar.Size.Height);
            else
            {
                self_lifebar.Size = new Size(1, self_lifebar.Size.Height);
                BattleLogWrite("Du stirbst", false);
                wait.Stop();
                return;
            }
        }
        void BattleLogWrite(string text, bool self)
        {
            if (self)
                self_battle.Text = self_battle.Text + text;
            else
                enemy_battle.Text = enemy_battle.Text + text;
            self_battle.SelectionStart = self_battle.Text.Length;
            self_battle.ScrollToCaret();
            self_battle.Refresh();
            enemy_battle.SelectionStart = enemy_battle.Text.Length;
            enemy_battle.ScrollToCaret();
            enemy_battle.Refresh();
            wait.Start();
        }
        #endregion

        #region GetStats
        double GetLife(int stamina, int multi, int level)
        {
            return stamina * multi * (0.5 + level / 2);
        }
        double GetCrit(int luck, int level)
        {
            return luck * 25 / (level * 10);
        }
        double GetAttackPower(int weapondamage, int attribute)
        {
            return weapondamage * (1 + attribute / 10);
        }
        int GetResistance(int attribute)
        {
            return attribute / 2;
        }
        double GetDamageReuction(int level, int armor)
        {
            return (armor / level);
        }
        #endregion

        private void wait_Tick(object sender, EventArgs e)
        {
            Sim();
        }

        private void button8_Click(object sender, EventArgs e)
        {
            Sim();
        }

        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            this.ClientSize = new System.Drawing.Size(1094, 527);
            this.UpdateStyles();
        }
    }
}